Welcome Guest, Not a member yet? Register   Sign In
.htaccess question
#1

[eluser]James Burton[/eluser]
Hey all, .htaccess is something that really confuses me and anything I try to read about it seems to go right over my head. So I'm hoping somebody can help me with this. Smile

I currently have the following code.

Code:
#remove www. from the uri and redirect with a 301 code.
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

#Remove trailing slash from url
RewriteCond %{HTTP_HOST} !^\.example\.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

The problem I have found is that if a user is to enter http://www.example.com/something/ they are redirected twice, firstly to remove the www and then again to remove the trailing slash.

Would it be possible to combine these rules so that it both removes the www and any trailing slashes in just one redirect?

Thanks for the help. :-)




Theme © iAndrew 2016 - Forum software by © MyBB