How to make mod_rewrite suppress the processing of more rules?

Given my current .htaccess file, how do I change it to check for an additional url like '/ src / pub /' and rewrite it to '/' without affecting the current rewrite?

Here is the source .htaccess file:

RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?route=$1 [L,QSA] 

and here is my recent attempt (which does not work):

 RewriteEngine on RewriteRule ^/src/pub/(.*)$ /$1 [R] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?route=$1 [L,QSA] 

Edit: Here are some examples of what I want to accomplish:

New additional rule:

 From: http://www.mysite.com/src/pub/validfile.php To: http://www.mysite.com/validfile.php From: http://www.mysite.com/src/pub/user/detail/testuser To: http://www.mysite.com/user/detail/testuser 

Existing rule (already working):

 From: http://www.mysite.com/user/detail/testuser To: http://www.mysite.com/index.php?route=user/detail/testuser 
+4
source share
2 answers

I assume the problem is that the URL is rewritten by the first rule, and then rewritten by the second.

The solution to this issue is to add the β€œlast” flag to the first rule, for example:

 RewriteRule ^/src/pub/(.*)$ /$1 [R,L] 
+5
source

in the .htaccess file use instead:

 RewriteRule ^src/pub/(.*)$ /$1 [R] 

the leading character "/" will not match .htaccess, only inside httpd.conf ( src is at the bottom of the page), if you want the processing of further rules to stop, then add the L flag:

 RewriteRule ^src/pub/(.*)$ /$1 [L,R] 

rewrite log comparison (.htaccess context):

 // using ^/src/pub/(.*)$ - leading slash will not work in .htaccess context! (1) pass through /home/test/src // using ^src/pub/(.*)$ (2) rewrite 'src/pub/testme' -> '/testme' (2) explicitly forcing redirect with http://test/testme (1) escaping http://test/testme for redirect (1) redirect to http://test/testme [REDIRECT/302] 
+3
source

All Articles