| Rewrite - not working
|
Andrew Thomas

msg:1522111 | 3:16 pm on Sep 28, 2004 (gmt 0) | Im new to apache, but am trying to set setup 301 pernament redirects. eg www.widgets.com and www.red-widgets.com both redirect to www.widgets.co.uk I used the following code: RewriteEngine On RewriteCond %{HTTP_HOST} ^widgets.com$ [NC] RewriteCond %{HTTP_HOST} ^red-widgets.com$ [NC] RewriteRule ^(.*)$ [widgets.co.uk...] [R,L] when run, the site just says "forbidden" Is the above code correct? Without asking my hosts, is there a way to see which modules/directives are running on the server? (code to detect them?) thanks
|
jdMorgan

msg:1522112 | 3:36 pm on Sep 28, 2004 (gmt 0) | Andrew, I'm assuming you've placed the code in .htaccess in your Web root directory. If so, try the following:
Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^widgets\.com [NC,OR] RewriteCond %{HTTP_HOST} ^(www\.)?red-widgets\.com [NC] RewriteRule ^(.*)$ http://www.widgets.co.uk/$1 [R=301,L]
Options +FollowSymLinks or Options +SymLinkIfOwnerMatch is required in order to use mod_rewrite. The domain names should not be end-anchored in order to prevent rule failure in case a port number is appended, e.g. "widgets.com:80/index.html". This is a relatively simple rewrite, so if it does not work, then it's likely that mod_rewrite is not enabled on your server -- Check your server error log to see what it says. Jim
|
Andrew Thomas

msg:1522113 | 4:22 pm on Sep 28, 2004 (gmt 0) | thanks, that worked fine
|
Andrew Thomas

msg:1522114 | 8:21 am on Oct 6, 2004 (gmt 0) | I understand most of this, RewriteCond %{HTTP_HOST} ^widgets\.com [NC,OR] but why is the \ before the .com thanks
|
jdMorgan

msg:1522115 | 12:45 pm on Oct 6, 2004 (gmt 0) | > but why is the \ before the .com Because the period has special meaning to the regular-expressions pattern-matching language used in mod_rewrite. Without a preceding the slash, a period in a pattern means "match any character." Any character that has special meaning in regular expressions must be escaped if used inside a pattern. In this case, it is used to specify that you want a literal period to match, and not just any character. More info is available in the regular-expressions tutorial cited in our charter. Jim
|
|
|