: RewriteRule RewriteCond These codes dont work together... How can I integrate both codes? # Block#1 RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^search/(.+?)/(d+)/?$ /search.php?q=&p= [L,QSA,NC]
These codes dont work together... How can I integrate both codes?
# Block#1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^search/(.+?)/(d+)/?$ /search.php?q=&p= [L,QSA,NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+search.php?q=([^s]+)&p=(d+) [NC]
RewriteRule ^ /search/%1/%2? [R=302,L]
# Block#2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^search/(.+?)/(d+)/(d+)/?$ /search.php?q=&p=&ty= [L,QSA,NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+search.php?q=([^s]+)&p=(d+)&ty=(d+) [NC]
RewriteRule ^ /search/%1/%2/%3? [R=302,L]
More posts by @Si4351233
1 Comments
Sorted by latest first Latest Oldest Best
mod_rewrite directives execute top-down, so the most specific rules should come before the more general rules.
In your code above you need to reverse code Block#1 and Block#2. ie. check for 3 URL params before checking for 2 URL params.
Alternatively, match the exact URL (rather than just a prefix) in the CondPattern (2nd argument to the RewriteCond directive). Perhaps by matching a trailing space in the THE_REQUEST variable. eg ...&p=(d+)s [NC]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.