Forum Moderators: phranque
I alreay read these:
[webmasterworld.com...]
[webmasterworld.com...]
posts on the issue and also several others.
What I want to do is: sub.domain.co.uk => www.domain.co.uk/sub
The code I came up with:
rewriteCond %{REQUEST_URI}!^/index\.php
rewriteCond %{HTTP_HOST}!^www\.
rewriteCond %{HTTP_HOST} ^(.+)\.domain\.co\.uk
rewriteRule ^(.*) [domain.co.uk...] [L]
Result: 500 Internal Server Error
Any ideas?
Welcome to WebmasterWorld!
Any ideas?
Yes, please review and post the pertinent information from your server error log. It will often tell you exactly what's wrong.
I assume you're placing this code in .htaccess in your Web root directory. If placed in httpd.conf, minor changes will be required. If this is the only mod_rewrite code you have, then you will also need some "setup" directives.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.co\.uk
RewriteRule (.*) /%1/$1 [L]
Jim
Error.log:
[Thu Aug 25 00:08:18 2005] [alert] .htaccess:
RewriteCond: bad argument line '%{REQUEST_URI}!^/index\.php'
I'm further rewriting it the following way:
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^([^/]+)/$ index.php?var=$1 [L,NC]
Thank you for any help.
Your additional code with the "!-d" RewriteCond also needs an exclusion for index.php, since that won't exist as a directory. Without an exclusion, the code will loop and cause an error.
Jim