517 Posts in 277 Topics by 221 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 912 Views |
-
Issues with .htaccess and non www redirects

3 July 2011 at 1:40am
I have a SS site set up on a server with hostgator no problems at all, however this site will also contain another SS "Add on Domain" which is installed into the public_html folder as addondomain.com, the problem i am having is with the url rewrites from non www to www. this is what i have:
Main domain:
### SILVERSTRIPE START ###
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files><Files web.config>
Order deny,allow
Deny from all
</Files>
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html<IfModule mod_alias.c>
RedirectMatch 403 /silverstripe-cache(/|$)
</IfModule><IfModule mod_rewrite.c>
DirectoryIndex index.php
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase /RewriteCond %{HTTP_HOST} !^www\.maindomain\.com$
RewriteRule (.*) http://www.maindomain.com/$1 [R=301,L]RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
### SILVERSTRIPE END ###in the add on domain htaccess:
### SILVERSTRIPE START ###
<IfModule mod_dir.c>
DirectorySlash Off
</IfModule>RewriteEngine On
RewriteBase /RewriteCond %{HTTP_HOST} ^addondomain.com [NC]
RewriteRule ^(.*)$ http://www.addondomain.com/$1 [R=301,NC,L]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 ###as advised the rewrite conditions for non www to www are running below RewriteBase, but what is happening is for both domains the urls from non www do get rewritten but at the end of the url they are suffixed with .com/sapphire/main.php?url=/ this is for both domains, i also tried to force non www through via mysite _config.php but this has the same result.. any ideas? thanks
-
Re: Issues with .htaccess and non www redirects

3 July 2011 at 4:45am
All sorted, originaly when installing the add on domain the main .htaccess file would thorw out a 500 error so i used a different kind of set up htaccess to get around this so i could install, thinking that the error would come back i left it as is, but actually the right thing was to have it with the same .htaccess that is in the add on domain folder... now all is hunky dory!
| 912 Views | ||
|
Page:
1
|
Go to Top |

