Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite php with domain rewrite rule

htaccess causes 500 error

         

moneybagsuk

8:11 pm on Apr 9, 2006 (gmt 0)

10+ Year Member



Hi there,

I am pretty new to htaccess and mod rewrite and have a quandary I can't figure out.

I am trying to rewrite a domain to mysite/forums. I have read the info in the thread below and added it to my htaccess file. But as soon as I upload it my site reverts to a 500 error.

Can anyone help? I have rewrites working in a subdirectory of my site so I can't see why this doesn't work at root, unless there is some conflict between the php bit and the rewrite!?

Thanks for your help!

[webmasterworld.com...]

My .htaccess looks like this:

AddHandler application/x-httpd-php .php .html
AddHandler server-parsed .html .shtml
AddType 'text/html; charset=ISO-8859-1' html
RewriteEngine On
rewriteCond %{HTTP_HOST} ^www\.mydomainname2\.co.uk
rewriteCond %{REQUEST_URI}!/forums/
rewriteRule (.*) /forums/$1 [L]
rewriteCond %{HTTP_HOST} ^mydomainname2\.co.uk
rewriteCond %{REQUEST_URI}!/forums/
rewriteRule (.*) /forums/$1 [L]

jdMorgan

10:12 pm on Apr 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need two rules if you make the "www." subpattern optional (see below), and check that you have the required space between "}" and "!" in your second RewriteCond (posting on this forum deletes that space, unless you use a work-around).

AddType 'text/html; charset=ISO-8859-1' html
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?mydomainname2\.co.uk
RewriteCond %{REQUEST_URI} !/forums/
RewriteRule (.*) /forums/$1 [L]

Jim

moneybagsuk

7:03 pm on Apr 10, 2006 (gmt 0)

10+ Year Member



got it - thanks alot!