.htaccess - Two rewrite rules don't cooperate -


i'd rewrite 2 things on 1 site.

mysite.com/something -> mystie.com/index.php?s=something 

and

mysite.com/something/another -> mysite.com/index.php?s=something&d=another 

this htaccess

rewriteengine on rewriterule ^(.+)$ index.php?s=$1 [l,qsa] rewriterule ^(.+)/(.+)$ index.php?s=$1&d=$2 [l,qsa] 

separately both work don't...

i'm guessing problem you're matching '/' character in first rule. wouldn't easiest solution add character class rules, like:

rewriterule ^([a-z0-9]+)$ index.php?s=$1 [l,qsa] rewriterule ^([a-z0-9]+)/([a-z0-9]+)$ index.php?s=$1&d=$2 [l,qsa] 

or change order of rules:

rewriterule ^(.+)/(.+)$ index.php?s=$1&d=$2 [l,qsa] rewriterule ^(.+)$ index.php?s=$1 [l,qsa] 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -