Forum Moderators: phranque

Message Too Old, No Replies

403 Mod Rewrite error

         

alexswalker

11:56 am on Feb 2, 2004 (gmt 0)

10+ Year Member



Hi,

I am trying to setup a 301 redirect on one of my doamins so it poisnts to my main site. However when using mod rewrite I get a 403 Forbidden error.

This is in my .htaccess:

RewriteEngine On
Options +FollowSymlinks
RewriteRule ^/(.*) [mydomain.com...] [R=301,L]

This is my error log:

[Mon Feb 2 05:50:45 2004] [error] [client 131.111.195.211] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /home/virtual/site27/fst/var/www/html

dcrombie

1:18 pm on Feb 2, 2004 (gmt 0)



You might find an answer in this thread [webmasterworld.com]

alexswalker

11:15 am on Feb 3, 2004 (gmt 0)

10+ Year Member



Thanks for the link but it doesn't really help!

jdMorgan

9:32 pm on Feb 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



alexswalker,

The implication of the cited thread is that you cannot use a mod_rewrite directive before you enable mod_rewrite using Options +FollowSymLinks.

Therefore, you must reverse the order of your first two directives.

In addition, you will need to exclude the "correct" domain from being rewritten -- Otherwise, you'll get an infinite rewrite loop.

The "classic" code for doing this is:


RewriteCond %{HTTP_HOST} !^www\.correctdomain\.com
RewriteRule (.*) http://www.correctdomain.com/$1 [R=301,L]

This says, "If not the correct domain, permanently redirect all resource (page, image, script, etc.) requests to the correct domain."

You will need your first two lines with this code, too.

Ref: Introduction to mod_rewrite [webmasterworld.com]

Jim