LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-13-2010, 07:15 AM   #1
charu
Member
 
Registered: Nov 2010
Posts: 35

Rep: Reputation: 0
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..
 
Old 12-13-2010, 07:57 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,900

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
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
 
1 members found this post helpful.
Old 12-13-2010, 10:05 AM   #3
charu
Member
 
Registered: Nov 2010
Posts: 35

Original Poster
Rep: Reputation: 0
Thanks, that explains why my sitemaps were throwing up all sorts of odd urls, if I required that rewrite condition!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mod rewrite redirect nuttynibbles Linux - General 4 06-19-2010 05:57 PM
[SOLVED] Apache MOD REWRITE yoachan Linux - Server 4 01-21-2010 02:15 AM
conf :Mod rewrite,Mod Jkand virtualhosts ayyappansan Linux - Server 1 10-25-2009 04:10 AM
Apache2 mod vhost_alias - problems with .htaccess mod rewrite d_t_baker Linux - Server 1 08-16-2007 08:32 PM
Mod Rewrite Help carminejg3 Linux - Software 0 12-20-2004 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration