Mobile app version of vmapp.org
Login or Join
Si4351233

: 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]

@Si4351233

Posted in: #Htaccess #ModRewrite

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]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Si4351233

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

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]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme