Mod_rewrite from within a subdomain

redcable
redcable used Ask the Experts™
on
I added a sub domain to our company website demo.companyname.com then edited the DNS to point to my home webserver. However I cannot get mod_rewrite to work correctly. I recieve 500 Internal Server Errors and my log says

"Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace."

I added RewriteLog and RewriteLogLevel 5 to my apach2.conf but it does not create a report when accessing pages that use mod_rewrite.

here is a copy of my .htaccess file

#### SEFU
Options +FollowSymLinks
RewriteEngine On

# ONLY rewrite URIs beginning with /
RewriteCond %{REQUEST_URI} ^/.* [NC]
# Don't rewrite any URIs ending with a file extension (ending with .[xxxx])
RewriteCond %{REQUEST_URI} !\.[a-zA-Z]{2,4}$
# Don't rewrite admin directory
RewriteCond %{REQUEST_URI} !^/admin.* [NC]
# Don't rewrite editors directory
RewriteCond %{REQUEST_URI} !^/editors.* [NC]
# Don't rewrite cPanel directories
RewriteCond %{REQUEST_URI} !/cpanel.* [NC]
RewriteCond %{REQUEST_URI} !/frontend.* [NC]
# Handle all other URIs (index.php)
RewriteRule (.*) index.php?%{QUERY_STRING} [L]

#### SEFU

please help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David S.Consultant & Challenge Subduer
Top Expert 2009

Commented:
Try changing

RewriteRule (.*) index.php?%{QUERY_STRING} [L]

to

RewriteRule ^/(.*)$ index.php?page=$1 [L,QSA]

Author

Commented:
I am not pretty confident its a configuration error on my end with the virtualserver setup on my home webserver and not with the .htaccess file.
Top Expert 2010

Commented:
Try the following:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/.* [NC]
RewriteCond %{REQUEST_URI} !\.[a-zA-Z]{2,4}$
RewriteCond %{REQUEST_URI} !^/(admin|editors) [NC]
RewriteCond %{REQUEST_URI} !/(cpanel|frontend) [NC]
RewriteRule (.*) /index.php [L]

Open in new window

C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Author

Commented:
arober11. that worked, and the page now shows up without giving a 500 internal server error. however the error log is still spitting out

"Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace."
David S.Consultant & Challenge Subduer
Top Expert 2009

Commented:
Well you asked for help and we only have the information you provided.

Another possibility might be that there's nothing to stop the rewritten URL from being rewritten again.

Try this:
#### SEFU
Options +FollowSymLinks
RewriteEngine On
 
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/index.php$  - [L]
 
 
# ONLY rewrite URIs beginning with /
RewriteCond %{REQUEST_URI} ^/.* [NC]
# Don't rewrite any URIs ending with a file extension (ending with .[xxxx])
RewriteCond %{REQUEST_URI} !\.[a-zA-Z]{2,4}$
# Don't rewrite admin directory
RewriteCond %{REQUEST_URI} !^/admin.* [NC]
# Don't rewrite editors directory
RewriteCond %{REQUEST_URI} !^/editors.* [NC]
# Don't rewrite cPanel directories
RewriteCond %{REQUEST_URI} !/cpanel.* [NC]
RewriteCond %{REQUEST_URI} !/frontend.* [NC]
# Handle all other URIs (index.php)
RewriteRule (.*) index.php?%{QUERY_STRING} [L]
 
#### SEFU

Open in new window

Top Expert 2010

Commented:
Not thinking tonight, try:


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteCond %{REQUEST_URI} ^/ [NC]
RewriteCond %{REQUEST_URI} !\.[a-zA-Z]{2,4}$
RewriteCond %{REQUEST_URI} !^/(admin|editors) [NC]
RewriteCond %{REQUEST_URI} !/(cpanel|frontend) [NC]
RewriteRule (.*) /index.php [L]

Open in new window

Top Expert 2010
Commented:
Or:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(index.php|admin|editors) [NC]
RewriteCond %{REQUEST_URI} !\.[a-zA-Z]{2,4}$
RewriteCond %{REQUEST_URI} !/(cpanel|frontend) [NC]
RewriteRule (.*) /index.php [L]

Open in new window

Author

Commented:
Thanks

Author

Commented:
any reason why this worked and the original htaccess didnt, considering that the original is what is working on the production servers www.domain.com address?
Top Expert 2010

Commented:
Hi

The "Request exceeded the limit of 10 internal redirects due to probable configuration error...."  errors were down to /index.php  requests being subject to inspection by the rule, after the initial re-direct, just needed to be explicitly excluded.

Oh:
?%{QUERY_STRING}

is automatically appended by apache, so redundant, as was:

 RewriteCond %{REQUEST_URI} ^/.* [NC]

as always true.

As to the 500 errors, have a look in you apace error_log, there should be something in there, else up your:

RewriteLogLevel 9

and have another play with your original rules.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial