Quote:
Originally Posted by DeadSilent
I have a similar question on the same matter. I'm wonder how I can use multiple RewriteRules for different files.. currently I am only able to Rewrite one and if I use any more they either dont work or will cause an error.. here is the code I'm using:
-
<IfModule mod_rewrite.c>
-
Options +FollowSymlinks
-
RewriteEngine on
-
RewriteCond %{REQUEST_FILENAME} !-f
-
RewriteCond %{REQUEST_FILENAME} !-d
-
RewriteRule ^(.*)$ link.php?get=$1 [L,QSA]
-
</IfModule>
-
I'd like to add the code below for basic actions:
-
RewriteRule ^(.*)$ index.php?do=$1 [L,QSA]
-
then i'd like to have this one
-
RewriteRule ^(.*)$ index.php?do=$1&search=$2&type=$3&page=$4 [L,QSA]
-
which turns out like: /search/$2
If you could give me some help as well that would be great.. I'm starting to learn this stuff but I still dont get it.. :\
Thanks guys.
You are searching the URI for the same match on each rewrite rule. So Apache doesn't know which one you wish to match.
This match is true if the url matches "any" character. One or more times from beginning to end of url.
RewriteRule ^(.*)$ index.php?do=$1 [L,QSA]
This one also matches the same criteria.
RewriteRule ^(.*)$ link.php?get=$1 [L,QSA]
How are you going to specify when to "do" or "get"?
Also, the capture only occurs once. So you have not populated $2, $3 etc...
The last rewrite rule will always fail.
RewriteRule ^(.*)$ index.php?do=$1&search=$2&type=$3&page=$4 [L,QSA]
Here's a good article.
Apache Mod_rewrite