LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Regular Expression For Mod Rewrite (https://www.linuxquestions.org/questions/linux-newbie-8/regular-expression-for-mod-rewrite-849907/)

charu 12-13-2010 06:15 AM

Regular Expression For Mod Rewrite
 
I have this..
RewriteRule ^(apes|ape)/(.*)$ $2?fh=$1 [L,QSA]

I only want to match the directories ape/ and apes/ but I think it is matching any directory that ends in "ape" or "apes" or maybe does it match any string containing those characters in any order?

I am not great at regex, and have read alot, but still not sure if I understand this correctly..

bathory 12-13-2010 06:57 AM

Hi,

If you want the rule to apply only for /ape/(.*) or /apes/(.*), you need a rewrite condition first so the rule will be applied to those URIs that meet the condition:
Code:

RewriteCond %{REQUEST_URI} ^/(apes|ape)/(.*)
RewriteRule ^(apes|ape)/(.*)$ $2?fh=$1 [L,QSA]

Regards

charu 12-13-2010 09:05 AM

Thanks, that explains why my sitemaps were throwing up all sorts of odd urls, if I required that rewrite condition!


All times are GMT -5. The time now is 09:42 AM.