Reputation: 71
Hi guys i need help with apache htaccess. I've this 2 url:
how i can catch in a different way this 2 situations?
actually i've this htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/test/admin[NC]
RewriteCond %{REQUEST_URI} !^/test/(it|en) [NC]
RewriteRule ^(.*)$ /test/en/$1 [R=301,L,QSA]
RewriteRule ^([\w-]+)/([\w-]+)/(\d+)/([\w-]*)$ /test/index.php?detMod=$3 [L,QSA,NC]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/([\w-]*)$ /test/index.php?page=$2&category=$3 [L,QSA,NC]
But i need another rule for the case of number (1564) instead of the (guns2)
Upvotes: 1
Views: 31
Reputation: 785216
Use \d+
to match only numbers and use [\w-]+
to match alphanumerics, _
and -
:
^([\w-]+)/([\w-]+)/(\d+)/([\w-]*)$
and
^([\w-]+)/([\w-]+)/([\w-]+)/([\w-]*)$
Suggested .htaccess:
RewriteCond %{REQUEST_URI} !^/test/admin[NC]
RewriteCond %{REQUEST_URI} !^/test/(it|en) [NC]
RewriteRule ^(.*)$ /test/en/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([\w-]+)/([\w-]+)/(\d+)/([\w-]*)$ test/index.php?detMod=$3 [L,QSA,NC]
RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)/([\w-]*)$ test/index.php?page=$2&category=$3 [L,QSA,NC]
Upvotes: 1