Welcome to WebmasterWorld Guest from 35.170.81.210

Forum Moderators: bakedjake

Message Too Old, No Replies

301 "Mod Rewrite" for Linux Server HTAccess

How to use the mod_rewrite in Linux

     
2:16 pm on Apr 13, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 12, 2003
posts:725
votes: 0


I usually work on Apache servers, and using this code to do a rewrite of non-www to www fails. In fact, the site fails to load because of it.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST}!^www\.domain\.co\.uk [NC]
RewriteRule ^(.*)$ [domain.co.uk...] [L,R=301]
</IfModule>

Is there an issue with Linux that it won't accept this mod_rewrite?

Cheers,

CaboWabo

2:00 pm on Apr 14, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 12, 2005
posts:371
votes: 0


CaboWabo,

That should work on a Linux/Apache server just fine. I tested it just now on one, and it worked. One change I would make is to test that an HTTP_HOST is being passed through, as there won't always be one:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.co\.uk [NC]
RewriteRule (.*) [domain.co.uk...] [L,R=301]
</IfModule>

Chad

4:39 pm on Apr 14, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 12, 2003
posts:725
votes: 0


Thanks for the reply ... and the issue was me - I'm an idiot. It's always the easiest thing .... mod_rewrite was not functional on the server. It is always the easiest issue isn't it? I'll crawl back in my hole now.

CaboWabo

5:29 pm on Apr 14, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 12, 2005
posts:371
votes: 0


Haha, in this case, blame the server - everyone should support mod_rewrite! Glad you got it figured out...

Chad

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members