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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.