Persisting http://foo.bar/$ > http://www.foo.bar/$

Discuss practical ways rearrange URLs using mod_rewrite.

Persisting http://foo.bar/$ > http://www.foo.bar/$

Postby ahxcjb » Sat Dec 09, 2006 12:35 pm

Hi,

When I worked at Zeus I wrote a script that performed the above. It's referenced at: http://knowledgehub.zeus.com/code/2006/ ... ame_com_to

All the examples i've seen of http:// > http://www rely on inputting a domain name - this I do not wish to have to do for all the domains I am responsible for hosting.

I'm looking to implement this type of persistence within mod_rewrite on Apache2. Is there anyway to put certain fields into variables - I can't currently seem to find the right way to do what I can in ZWS/ZXTM..

Any help anyone, esp Richard, could give would be appreciated.

All the best,
Chris
ahxcjb
 
Posts: 2
Joined: Sat Dec 09, 2006 12:29 pm

Postby richardk » Sat Dec 09, 2006 12:41 pm

I think you might want this:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

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

Postby ahxcjb » Sat Dec 09, 2006 12:43 pm

richardk wrote:I think you might want this:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


Good grief that was a wonderfully fast response! How did I miss that rewrite! :(

Richard, great stuff - thankyou for your wonderful efforts in the FOSS community.

All the best,
Chris
ahxcjb
 
Posts: 2
Joined: Sat Dec 09, 2006 12:29 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 1 guest