Forum Moderators: phranque

Message Too Old, No Replies

redirect to folder fail with server error 500

         

chip

1:00 am on Feb 27, 2005 (gmt 0)

10+ Year Member




Hi,

I have tried to add redirection to a folder, but I get an error. Please help anyone ...

RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\.domain\.net
RewriteRule .* /somefolder [L]

Thank You

-chip

jdMorgan

1:15 am on Feb 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Chip,

Welcome to WebmasterWorld!

What does your server error log say? That's the first place to check.

The most likely cause is that you need to add:


Options +FollowSymLinks

To the beginning of your code in order to enable mod_rewrite.

As written, you code will redirect *all* requests, including those for images, scripts, CSS files, etc. to the default index file of /somefolder. If you want to preserve the requested filename, then your code should look like this:


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\.domain\.net
RewriteRule (.*) /somefolder/$1 [L]

Otherwise, just try adding the Options directive as shown.

Jim

chip

2:44 am on Feb 27, 2005 (gmt 0)

10+ Year Member



Thank you Jim for your instant reply :-)

FollowSymLinks is on.

access_log say:
"GET / HTTP/1.1" 500 - "-"

error_log say:
mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.

I don't understand this. I have several rewrites for other domains, I tried to remove all of them and only include the subdomain rewrite mentioned. Still the same error.
When I have the other rewrites they work fine.

Best Regards,
-chip

chip

3:12 am on Feb 27, 2005 (gmt 0)

10+ Year Member




From my httpd.conf virtualhost entry it says:
ServerAlias orgdomain.info www.orgdomain.info

In my nameserver the abc.domain.net is CNAME to orgdomain.info

Could it be that it will work if abc.domain.net CNAME to www.orgdomain.info instead (because of the ServerAlias in httpd.conf)?

-chip

jdMorgan

4:05 am on Feb 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This should fix it:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc\.domain\.net
RewriteCond %{REQUEST_URI} !^/somefolder/
RewriteRule (.*) /somefolder/$1 [L]

There was nothing in the original code to prevent the rewritten request from being rewritten again and again. In .htaccess context, any substituted URL-paths (output URL-paths from RewriteRule) must be re-processed through httpd.conf and then again through any .htaccess files in the new path to check for any further rewrites or access restrictions that may apply to that new URL-path. So essentially, your code was recursive.

Jim

[edited by: jdMorgan at 4:27 am (utc) on Feb. 27, 2005]

chip

4:19 am on Feb 27, 2005 (gmt 0)

10+ Year Member



Thank you very much, that did the trick!

BIG :-)

The Best,
-chip