5093 Posts in 1516 Topics by 1113 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 3057 Views |
-
htaccess - rewrite no www to www problem

15 May 2009 at 6:02am
Hi all,
I am adding this to my .htaccess:
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]So that I can redirect all "non-www" users to "www" users. However, when I do this, I get redirected to www.mysite.com/sapphire/main.php?url=/ and then I get a 404 error.
How can I get this to work correctly with the framework?
-
Re: htaccess - rewrite no www to www problem

15 May 2009 at 7:26am
############ Redirect for Google
RewriteCond %{HTTP_HOST} !^www.lemon8.nl$ [NC]
RewriteRule ^(.*)$ http://www.lemon8.nl/$1 [L,R=301]
############Works for me ?
-
Re: htaccess - rewrite no www to www problem

17 May 2009 at 10:42pm
Just put Director::forceWWW() in mysite/ _config.php
-
Re: htaccess - rewrite no www to www problem

18 September 2009 at 4:01am Last edited: 18 September 2009 4:11am
If I put Director::forceWWW(); into my _config file, the users going to the non WWW version are redirected to http://www.example.com/sapphire/main.php?url=/
How can I get them to just be redirected to http://www.example.com ?
-
Re: htaccess - rewrite no www to www problem

4 February 2010 at 3:59pm
I had the same problem. Here's what my code looked like:
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,NC]Here's what worked:
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,NC,L]I tried Dan's flags and it did work for me, so not sure what was going on there. The Director forceWWW method is more elegant, but I'd rather have this processed before it hits the CMS.
-
Re: htaccess - rewrite no www to www problem

5 February 2010 at 8:10am
Dan, are you adding the rules before or after the SilverStripe rewriting rules? The order is important - it would be before, but I think you have them after.
-
Re: htaccess - rewrite no www to www problem

19 February 2010 at 6:50pm
Yes, the order of this redirect is important. the following is what I have used on my site.
### SILVERSTRIPE START ###
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files><IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /RewriteCond %{HTTP_HOST} ^mydomain\.com\.au$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com.au/$1 [R=301,L]RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$)
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>
### SILVERSTRIPE END ### -
Re: htaccess - rewrite no www to www problem

14 June 2011 at 3:53am
Hi.
I am trying to do a similar thing with a .co.uk to .com address but with no luck.
I have added this to my .htaccess file but the site still redirects to /sapphire/main.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.mysite\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$)
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
</IfModule>What am I doing wrong?
Thanks
Marc
| 3057 Views | ||
|
Page:
1
|
Go to Top |



