include parameter example.com/text ->www.example.com/text

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

include parameter example.com/text ->www.example.com/text

Postby FlemmingLeer » Sun Sep 13, 2009 3:42 am

First I could not bring this to work on my Apache/2.0.54 webhost:
viewtopic.php?p=12745#12745

It removed the domain name to http://www..com

But to include example.com/text in www.example.com/text use this:
Code: Select all
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]


corrected wrong parameter in RewriteCond :/
Last edited by FlemmingLeer on Sun Sep 13, 2009 3:45 pm, edited 1 time in total.
FlemmingLeer
 
Posts: 2
Joined: Sun Sep 13, 2009 3:06 am

Postby richardk » Sun Sep 13, 2009 11:53 am

First I could not bring this to work on my Apache/2.0.54 webhost:
viewtopic.php?p=12745#12745

Which one? Are you reporting an error or do you still have a problem?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby FlemmingLeer » Sun Sep 13, 2009 3:31 pm

Hi Richard,

I got the above error using this forcing of www:
Code: Select all
RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1%{REQUEST_URI} [R=301,L]


But now I can't reproduce this error :/

My bad.
FlemmingLeer
 
Posts: 2
Joined: Sun Sep 13, 2009 3:06 am

Postby richardk » Sun Sep 13, 2009 4:32 pm

If you remove the () from the RewriteCond it would cause that problem, that is probably what happened (%1 would not be set to example.com).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 37 guests

cron