View Full Version : rewritecond and rewriterule

02-08-2011, 03:00 AM

I'm trying to get my .htaccess file to redirect correctly.

Calling from the browser, http://somedomain.com/deals/

successfully triggers a behind the scenes rewrite:

RewriteCond %{REQUEST_URI} ^/deals/$ [NC]
RewriteRule ^deals/ /offers/listing.php?query=1 [L]

And that works. The server internally refers to offers/listing.php.

However, I want to set up the reverse. If a browser calls http://somedomain.com/offers/listing.php I want to do a 301 redirect to /deals/

RewriteCond %{REQUEST_URI} ^/offers/listing.php.*$ [NC]
RewriteRule ^.+ /deals/ [R=301,L]

I can't get that last bit to work. listing.php just loads.

Any help is appreciated!

One more thing, the "L" in the first rewrite rule should keep the rest of the htaccess from proscessing, correct?

02-08-2011, 03:12 AM

there was a .htaccess file in the /offers/ directory. Simply had RewriteEngine on.

Once I commented it out, the htaccess file I'm using in public_html worked.

Why would that be?

Also, the browser won't load the page and says it is redirecting in a way that will never complete. What might the solution to that be?