Link to home
Start Free TrialLog in
Avatar of joomla
joomlaFlag for Australia

asked on

RewriteCond

Hi, I need help to understand how RewriteCond works
RewriteRule ^([^/]+)/([^/]+) /index1.php?p=$1&NewsID=$2 [NC]
causes the url
mysite/news/NewsID=1
to display as
mysite/news/12 (where 12 is a record number)

How can I provide a condition which tests the value of $1
for example
if $1=news then
RewriteRule ^([^/]+)/([^/]+) /index1.php?p=$1&NewsID=$2 [NC]
elseif
$1=article then
RewriteRule ^([^/]+)/([^/]+) /index1.php?p=$1&ArticleID=$2 [NC]

also,
if there are less than 2 variables passed the rules are ignored?

thanks
ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joomla

ASKER

Kravimir
thanks for the wonderful examples.
i successfully tested the 'shorter alternative'.... thank you.

In terms of the second questions
I tried
RewriteRule ^newslist(/([^/]+))? /index1.php?p=news_list[NC]
with the expectation that
mysite/news_list
would give me the desire result.

Can you point out my error
thanks again.
Michael