Non-www to www not working with my other rules...

New to mod_rewrite? This is a good place to start.

Non-www to www not working with my other rules...

Postby novon » Mon Jul 13, 2009 2:04 pm

First off, hi to everybody... this is my first post :D

Ok, I've got the following rules in my htaccess:

Code: Select all
RewriteEngine On

RewriteRule ^the-lounge(.*)$ /lounge$1 [R=301]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


Basically I'd like http://www.mysite.com/the-lounge to redirect to http://www.mysite.com/lounge but that is not working. Any advice is greatly appreciated!
novon
 
Posts: 2
Joined: Mon Jul 13, 2009 1:36 pm

Postby richardk » Wed Jul 15, 2009 12:53 pm

What happens?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^the-lounge(/.*)?$ http://www.example.com/lounge$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby novon » Sun Jul 19, 2009 1:30 pm

It would either not redirect at all or do something like this:

http://www.example.com/http://www.example.com/lounge

I just tried your suggestion and it does exactly what I needed. Thank you very much for your help!
novon
 
Posts: 2
Joined: Mon Jul 13, 2009 1:36 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 27 guests

cron