Forum Moderators: phranque

Message Too Old, No Replies

Subdomain to Subdir problem

Read several threads on this issue and still have an error

         

kinchev

4:45 am on Aug 25, 2005 (gmt 0)

10+ Year Member



Hey guys,

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?

jdMorgan

8:02 pm on Aug 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



kinchev,

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]

I have also corrected some logic and syntax errors, and others that may be the result of this forum stripping required spaces from the code.

Jim

kinchev

1:05 am on Aug 27, 2005 (gmt 0)

10+ Year Member



Yes, I place it in .htaccess and I do have
Options +FollowSymLinks
RewriteEngine On.

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.

kinchev

2:44 am on Aug 28, 2005 (gmt 0)

10+ Year Member



Anyone?

Sorry for posting the second time.

jdMorgan

10:09 pm on Aug 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The error log shows that your RewriteCond is invalid, either due to a missing space between "}" and "!" or because of an invisible character in the line, perhaps added by a word-processor program (You should use only a plain-text editor to edit .htaccess).

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