tgeorge06 Posted January 4, 2011 Share Posted January 4, 2011 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 https://forums.phpfreaks.com/topic/223390-mod_rewrite-force-www-except-when-server-ip/ Share on other sites More sharing options...
johnny86 Posted January 5, 2011 Share Posted January 5, 2011 Would another condition help? RewriteCond %{HTTP_HOST} !192.168.1.1 RewriteCond %{HTTP_HOST} !^(www.|$) [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Link to comment https://forums.phpfreaks.com/topic/223390-mod_rewrite-force-www-except-when-server-ip/#findComment-1154972 Share on other sites More sharing options...
tgeorge06 Posted January 5, 2011 Author Share Posted January 5, 2011 negative, tried that to begin with. =/ Link to comment https://forums.phpfreaks.com/topic/223390-mod_rewrite-force-www-except-when-server-ip/#findComment-1155290 Share on other sites More sharing options...
Dragosvr92 Posted January 6, 2011 Share Posted January 6, 2011 http://www.webweaver.nu/html-tips/web-redirection.shtml Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] Link to comment https://forums.phpfreaks.com/topic/223390-mod_rewrite-force-www-except-when-server-ip/#findComment-1155746 Share on other sites More sharing options...
tgeorge06 Posted January 6, 2011 Author Share Posted January 6, 2011 how would a redirect help? why would i want to redirect http://192.168.1.1 to http://192.168.1.1? just for shits n giggles, I tried the redirect for ya... didn't work. Link to comment https://forums.phpfreaks.com/topic/223390-mod_rewrite-force-www-except-when-server-ip/#findComment-1155852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.