Forum Moderators: phranque

Message Too Old, No Replies

My article.php page wants to be in every directory!

How to stop calling article.php showing after every www.domain.com/directo/

         

scraptoft

7:00 pm on Sep 27, 2006 (gmt 0)

10+ Year Member



Hi first off I have been following WebmasterWorld for a number of months now and I have decided that now is a good time to get involved.

I have just finished setting up my .htaccess mod_rewrite which is working fine.

My .htaccess/mod_rewrite working:
www.domain.com/article.php?title=atitle

>
www.domain.com/$category/$title.

My problem is, that everything typed after www.domain.com/ (www.domain.com/everything/) calls up the article.php page.

Here is the part of mod_rewrite code from my .htaccess

RewriteRule ^([^/\.]+)/?$ /article.php?animal=$1 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /article.php?atype=$1&animal=$2 [L]

Any ideas to stop this on specific directories i.e /www.domain.com/images/

jdMorgan

11:46 pm on Sep 27, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are those "$" characters actually in the URL?

If so, modify your RewriteRule patterns to require them.

If not, you can add an exclusion to each rule:


RewriteCond %{REQUEST_URI} !^/images/

to exclude rewrites if any file in /images/ is requested.

However, I'd also suggest you add exclusions for robots.txt, /w3c/p3p.xml, labels.rdf or labels.xml, any any custom error pages, shared headers or footers, or shared client-side scripts you may have.

Note that a RewriteCond applies only to the first RewriteRule that follows it. You will ned the same exclusion for each rule. If the list of exclusions gets too long, you can re-arrange the code to avoid this duplication, but that's another subject.

Jim