I've searched on here and google and can't seem to get this right.
I have a .htaccess file in root ... I want all address to my site to go to a subdirectory (/foo.com/public_html/) and set the baseDirectory.
/.htaccess
Options +FollowSymLinks
Options -MultiViews
RewriteEngine on
RewriteBase /foo.com/public_html/
rewritecond %{http_host} ^bar.com [nc]
rewriterule ^(.*)$ http://www.bar.com/$1 [r=301,nc]
rewriterule ^$ /foo.com/public_html/ [nc]
Does this help:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursitename\.com$
RewriteRule (.*) http://www.yoursitename.com/$1 [R=301,L]
RewriteRule ^$ yoursub-directoryname[L]
Related
I'm trying to rename my domaine via htaccess fom http://old.com/page to http://new.com/page , in the first page http://new.com/ working fine, but when I want to go to other page I have 2 problems:
the the url not changed they have always the some text , like :
http://new.com/
the rewriting of page does not working until I
add .php like this : http://new.com/page.php
this is my htaccess code :
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^old\.com [NC]
RewriteRule ^/(.*) http://new.com/$1 [R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ http://new.com/$1 [R=301,NC]
RewriteRule ^page$ page.php [QSA,NC]
I'm really have no idea about this :(((
I may be wrong, but I think you don't need to add / in your RewriteRule ^/(.*) http://new.com/$1 [R=301,NC] line.
Try this and let me know (I havent tested it) :
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^old\.com [NC]
RewriteRule ^(.*) http://new.com/$1 [R=301,NC]
# -----------^-------- the change is here
This should redirect any page from old.com to the same page on new.com.
You can use this :
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
#redirect "olddomain.com/" to "newdomain.com/"
RewriteCond %{HTTP_HOST} ^old\.com [NC]
RewriteRule ^$ http://new.com/ [R=301,L]
#rewrite "olddomain.com/page" to "olddomain.com/.php"
RewriteRule ^page$ page.php [L,NC]
I try when user register on my site its profile open in subdomain
right now profile path is
mywebsite.com/page.php?usname=username
I want to convert this in to
username.mywebsite.com
I try various method given here but none of the work for me
I added *.mywebsite.com in DNS zone a record
and use this in my .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mywebsite.com
RewriteRule (.*) http://mywebsite.com/$1 [R=301,L]
RewriteRule ^([aA-zZ])$ page.php?usname=$1
RewriteCond %{HTTP_HOST} ^(^.*)\.mywebsite.com
RewriteRule (.*) page.php?usname=%1
this code not redirect to username.mywebsite.com
hope some give idea how to correct this .
Is this what you want?
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mywebsite.com$
RewriteRule ^(.*)$ http://mywebsite.com/$1 [R=301,L]
RewriteCond %{QUERY_STRING} usname=([^&]+)
RewriteRule ^page.php$ http://%1.mywebsite.com/ [L,R=301]
RewriteCond %{HTTP_HOST} ^(^.*)\.mywebsite.com
RewriteRule ^(.*)$ page.php?usname=%1
I am using htaccess to try and rewrite a url. I have tried about 10 versions of the code and examples but nothing makes any change. I know mod_rewrite is working because it is adding www to the url, but the vanity URL won't work.
RewriteRule ^franchise/([0-9]+)/?$ franchise-information.php?franchiseid=$1 [NC,L] # Handle product requests
Here is the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^franchise/([0-9]*?)/$ franchise-information.php?franchiseid=$1 [NC,L]
</IfModule>
And here is the URL:
http://www.playballkids.com/franchise-information.php?franchiseid=162
You can use this code in your DOCUMENT_ROOT/.htaccess file:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /franchise-information\.php\?franchiseid=([^\s&]+) [NC]
RewriteRule ^ franchise/%1? [R=302,L,NE]
RewriteRule ^franchise/(\d+)/?$ franchise-information.php?franchiseid=$1 [NC,L,QSA]
My SSL only covers swellnomore.com, not www.swellnomore.com.
I get a security error when i type https://www.swellnomore.com. Can this be fixed (forwarded to https://swellnomore.com ?
I had tried putting the following to htacess but did not helped too
# Override GoDaddy defaults that inhibit URL rewriting
Options -MultiViews
rewriteEngine On
# Rewrite URLs to remove www from domain name
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Before putting the above , htaccess looked like this
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteEngine On
RewriteBase /
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^swellnomore.com$
RewriteRule ^/?$ "https\:\/\/swellnomore\.com\/" [R=301,L]
P.S , I had already changed the site domain to
https://swellnomore.com in wp dashboard > general settings.
If you rewrite the domain , you should rewrite to https not to http
Try this rewrite rule:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
whole htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
# END WordPress
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Yes, it is possible. You just have to put this .htaccess in your root folder :
RewriteEngine On
RewriteBase /
RewriteRule ^/?$ http://sub.domain.com/this [L]
try this javascript
<script type='text/javascript'>
if(history.replaceState) history.replaceState({}, "", "/");
</script>
Note : where / is the path u want to show.
it shows the url like mysite.com no matter which link i have clicked. but i have a problem with this code while reloading the page the complete url with query string blink into address bar.
Update
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
Example: http://www.addondomain.com/projects/a/gallery/4/2 -> http://addondomain.com/projects/a/gallery/4/2
Maybe this will help you:
Add this to your .htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
I couldn't find the solution for "non-www" to "www" domain redirection. I have tried the following :
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]
# Remove index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
</IfModule>
So, how can I redirect, for example domain.com or www.domain.com to http://www.domain.com ?.
Something like should work :
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Here is what should help you:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
Can you try this ?
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
Seems apache mod_rewrite module is not enabled. So Make sure the Apache module mod_rewrite is enabled on your web server.
Try again this and see..It must work.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
See here - http://iyngaran.info, It is working. So no problem with the rule
How To Create Temporary and Permanent Redirects with Apache click hear
To automatically add a www to your domain name:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
or
.htaccess To Redirect URLs
To use htaccess to redirect URL just copy and paste the snippet below and replace example.com with your domain.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
More info true ans
Redirecting non-www to www with .htaccess