Forum Moderators: phranque

Message Too Old, No Replies

Need help troubleshooting recursive rewrite problem with .htacess

.htaccess mod_rewrite recursive

         

hmandir

6:35 pm on Sep 13, 2007 (gmt 0)

10+ Year Member



I am having a problem with a recursive rewrite in my .htaccess file. I am new to mod_rewrite, not that great with regex, and I think this .htaccess file is a bit complex. So, any help anyone can offer will be greatly appreciated.

This file mostly seems to do what I want it to. The specific problem I am having is that if I address the url something like [<example>.com...] then I get a page telling me that the server is redirecting the page in a way that will never complete. So far that is the only form of url that isn't working as expected... and I just can't figure out why it's trying to redirect at all.

If you've gotten this far in the message, I'm hoping that means you might be able to offer some help (or you might be able to get some help by reading any helpful responses).

I have a .htaccess file in my public_html/catalog/ directory that looks like this:


# The following makes adjustments to the SSL protocol for Internet
# Explorer browsers

<IfModule mod_setenvif.c>
<IfDefine SSL>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</IfDefine>
</IfModule>

RewriteEngine on
RewriteBase /catalog/

# prevent any php code from direct execution in these open folders
RewriteRule admin/backups/(.*)\.php $1.html [L]
RewriteRule admin/images/graphs/(.*)\.php $1.html [L]
RewriteRule debug/(.*)\.php $1.html [L]
RewriteRule images/(.*)\.php $1.html [L]
RewriteRule includes/key/(.*)\.php $1.html [L]
RewriteRule includes/languages/(.*)\.php $1.html [L]
RewriteRule pub/(.*)\.php $1.html [L]
RewriteRule temp/(.*)\.php $1.html [L]
RewriteRule tmp/(.*)\.php $1.html [L]

DirectoryIndex index.php default.php
Options +FollowSymLinks

RewriteRule ^.*\.gif¦\.jpg¦\.png¦\.css¦\.php$ - [L]

RewriteRule ^m([0-9]+_?[0-9]*)/?(.*)/p([0-9]+_?[0-9]*)/(.*)/product_info\.html$ product_info.php?manufacturers_id=$1&products_id=$3 [QSA,L]
RewriteRule ^p([0-9]+_?[0-9]*)/(.*)/product_info\.html$ product_info.php?products_id=$1 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/p([0-9]+_?[0-9]*)/(.*)/product_info\.html$ product_info.php?cPath=$2&products_id=$3 [QSA,L]

RewriteRule ^m([0-9]+_?[0-9]*)/?(.*)/p([0-9]+_?[0-9]*)/(.*)/index\.html$ index.php?manufacturers_id=$1&products_id=$3 [QSA,L]
RewriteRule ^m([0-9]+_?[0-9]*)/(.*)/index\.html$ index.php?manufacturers_id=$1 [QSA,L]

RewriteRule ^(.*)/c([0-9]+_?[0-9]*)/$ index.php?cPath=$2&products_id=$3 [QSA,L]

RewriteRule ^(.*)/c([^/]*)/p([0-9]+_?[0-9]*)/(.*)/index\.html$ index.php?cPath=$2&products_id=$3 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/index\.html$ index.php?cPath=$2 [QSA,L]

RewriteRule ^i([0-9]+_?[0-9]*)/(.*)/information\.html$ information.php?info_id=$1 [QSA,L]

RewriteRule ^p([0-9]+_?[0-9]*)/(.*)/pages\.html$ pages.php?pID=$1 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/p([0-9]+_?[0-9]*)/(.*)/pages\.html$ pages.php?cID=$2&pID=$3 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/pages\.html$ pages.php?cID=$2 [QSA,L]

RewriteRule ^(.*)/t([^/]*)/a([0-9]+_?[0-9]*)/(.*)/articles\.html$ articles.php?tPath=$2&articles_id=$3 [QSA,L]
RewriteRule ^(.*)/t([^/]*)/articles\.html$ articles.php?tPath=$2 [QSA,L]

RewriteRule ^a([0-9]+_?[0-9]*)/(.*)/article_info\.html$ article_info.php?articles_id=$1 [QSA,L]
RewriteRule ^(.*)/t([^/]*)/article_info\.html$ article_info.php?tPath=$2 [QSA,L]

RewriteRule ^p([0-9]+_?[0-9]*)/(.*)/product_reviews\.html$ product_reviews.php?products_id=$1 [QSA,L]
RewriteRule ^(.*)/c([^/]*)/p([0-9]+_?[0-9]*)/(.*)/product_reviews\.html$ product_reviews.php?products_id=$3 [QSA,L]

RewriteRule ^p([0-9]+_?[0-9]*)/(.*)/review([0-9]+_?[0-9]*)/product_reviews_info\.html$ product_reviews_info.php?products_id=$1&reviews_id=$3 [QSA,L]

RewriteRule ^f([0-9]+_?[0-9]*)/(.*)/faq\.html$ faq.php?cID=$1 [QSA,L]

RewriteRule ^(product_info¦index¦information¦pages¦articles¦article_info¦product_reviews¦product_reviews_info¦faq)\.html$ $1.php [QSA,L]


I would also appreciate any suggestions for improvements or optimization.

Thanks in advance.

[edited by: jdMorgan at 10:27 pm (utc) on Sep. 13, 2007]
[edit reason] Cleaned-up character-encoding prob noted below. [/edit]

hmandir

8:07 pm on Sep 13, 2007 (gmt 0)

10+ Year Member



I just saw that the pipe characters got changed to ¦ in my post. Just so you know (maybe obviously), they are actually backslashes in my file.

hmandir

9:24 pm on Sep 13, 2007 (gmt 0)

10+ Year Member



Oops! I meant pipes when I said backslashes in that last post. :)

jdMorgan

10:31 pm on Sep 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That URL doesn't trigger any of these rules, from what I can see. I'd suggest two alternate 'views' of the problem:

First, check your raw server error logs, and see what URL(s) or filepath(s) it is trying to redirect/rewrite to.

Then use the "Live HTTP Headers" extension for Firefox/Mozilla browsers to view the HTTP request and response headers, again with an eye to "following" the URLs in the redirects that are happening.

Also, what version of Apache are you running?

Jim