Forum Moderators: phranque
I'm using a gallery script which says to put the following rule into my .htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_URI}!.*__Auto-Gallery/wrapper\.php.*
RewriteRule .* /gallery/__Auto-Gallery/wrapper.php [NE,QSA,L]
As far as I can tell, it is meant to forward any requests for the gallery through the wrapper.php file. Fantastic, it works great!
But the problem I have is that any request for any other page on the site is processed through the wrapper.php as well and results in just the gallery being shown. ie. I can't access my home page unless I take out the rules.
I've played around with this rule all day but I can either get the site to show and no gallery or the gallery to show and no site. I can't get both.
Any pointers?
Cheers
# IF the requested URI is NOT <anything>__Auto-Gallery/wrapper.php<anything>
RewriteCond %{REQUEST_URI} !.*__Auto-Gallery/wrapper\.php.*
# THEN redirect all requests to yourdomain/gallery/__Auto-Gallery/wrapper.php, don't escape
# special characters, append query strings, do not process subsequent rewriterules
RewriteRule .* /gallery/__Auto-Gallery/wrapper.php [NE,QSA,L]
What you need to do is to figure out how to 'describe' the pages/files/resources that you *do not* want to rewrite. This can be done by taking advantage of something they have in common such as 'all files in subdirectory Bob' or 'all files that don't start with 'gallery', or you may just have to make a list of all of them. Once you have come up with a foolproof way to describe which resources should not be rewritten, you can exclude those resources from being rewritten by modifying the code.
See the references cited in our charter [webmasterworld.com] for more information.
Jim
Thanks for the pointers. Think I nailed it with :
#if the URL DOES NOT start with ___php
RewriteCond %{REQUEST_URI}!.*__phpAutoGallery/wrapper\.php.*
#AND the URL contains gallery
RewriteCond %{REQUEST_URI} .*gallery.*
#THEN REWRITE the URL
RewriteRule .* /gallery/__phpAutoGallery/wrapper.php [NE,QSA,L]
#ELSE do nothing
Please let me know if you can for see any problems with this method.
Thanks again.
#if the URL DOES NOT start with ___php
RewriteCond %{REQUEST_URI} !.*__phpAutoGallery/wrapper\.php.*
RewriteCond %{REQUEST_URI} [b]!^__p[/b]hpAutoGallery/wrapper\.php
Jim