I have a simple .htaccess file with the contents below.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?s=$1 [L]
</IfModule>
I want to add this rule.
RewriteRule ^p$ index.php?p=
I tried doing this below but it doesn't work. It seems like both rules are being run. I have tried a couple of different flags and again have had no luck. Could someone tell me how to get this working please.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^p$ index.php?p=
RewriteRule ^(.*)$ index.php?s=$1 [L]
</IfModule>
Best Answer
You must add
[L]
flag to stop reading rules when one match :Reminder of
RewriteRule
flags :Extract from this (very) complete post : https://serverfault.com/questions/214512/everything-you-ever-wanted-to-know-about-mod-rewrite-rules-but-were-afraid-to-as