17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1996 Views |
-
htaccess redirect

10 November 2008 at 11:51pm
Hi, I wonder if anyone can help. I'm really quite new to all this so apologies if this is a stupid question. I have just set up a new website using SilverStripe, however my old website (which was just a wordpress blog) still has all its pages listed in the search engines under the non-www domain. I am attempting to put a 301 redirect in the htaccess file to redirect from non-www to www where this new site is, by adding the bit to the bottom of the file:
### SILVERSTRIPE START ###
<IfModule mod_dir.c>
DirectorySlash Off
</IfModule>RewriteEngine On
RewriteBase /RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
### SILVERSTRIPE END ###RewriteCond %{HTTP_HOST} ^mydomain\.co.uk [nc]
RewriteRule (.*) http://www.mydomain.co.uk/$1 [R=301,L]However, for some reason every time I now type in http://mydomain.co.uk I am redirected to http://www.mydomain.co.uk/sapphire/main.php?url=/ instead of just http://www.mydomain.co.uk. Can anyone help with what this sapphire directory is for, and perhaps what I am doing wrong for it to redirect to it?
-
Re: htaccess redirect

11 November 2008 at 5:37am
Put the lines:
RewriteCond %{HTTP_HOST} ^mydomain\.co.uk [nc]
RewriteRule (.*) http://www.mydomain.co.uk/$1 [R=301,L]Below this:
RewriteEngine On
RewriteBase /The redirect for the www issue has to come before the other redirect stuff.
-
Re: htaccess redirect

11 November 2008 at 8:32am
Another way to do this is add:
Director::forceWWW();
to your _config.php file, this works just as well
| 1996 Views | ||
|
Page:
1
|
Go to Top |


