Jump to content

mod_rewrite force www except when server ip


tgeorge06

Recommended Posts

So I am using these rules

RewriteCond %{HTTP_HOST} !^(www.|$) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

 

But of course, thats catches everything and its brother, including the plain server ip  e.g. http://192.168.1.1  --> http://www.192.168.1.1

 

Which breaks it SO, i've been messing with this for 2 days, trying diff rules out trying to make up my own little mod_rewrite snipet of genius, BUT to no success... here i am.

 

I leave you, the mod_rewrite wizard, the task of solving the crime of rewriting my server ip to include a www. haha.

 

I would like to force www. for all domain names and leave ip addresses alone..

 

for instance, domain.com would be forced with www.

but http://192.168.1.1 would not.

 

Thanks in advance, much appreciated.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.