I want to write a rule that redirects all URLs of a certain pattern to a PHP file. Exception: the control/ directory where the CMS resides.
Why does
RewriteCond  %{REQUEST_URI} ^/([^control]+)/([^/]+)$   
RewriteRule .* /pages/index.php?language=%1&page=%2&%{QUERY_STRING} [L]
not work for
domain.com/deutsch/start
(it throws a 404), while
Rewr开发者_开发百科iteCond  %{REQUEST_URI} ^/([^control]+)/([^/]+)/debug$   
RewriteRule .* /pages/index.php?language=%1&page=%2&page_debug=yes&%{QUERY_STRING} [L]
works for
domain.com/deutsch/start/debug
?
You need to use two conditions:
RewriteCond %{REQUEST_URI} !^/control/
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$
RewriteRule .* /pages/index.php?language=%1&page=%2&%{QUERY_STRING} [L]
But you should use your pattern directly in the RewriteRule directive if possible:
RewriteCond $1 !=control
RewriteRule ^([^/]+)/([^/]+)$ /pages/index.php?language=$1&page=$2&%{QUERY_STRING} [L]
Another hint is to use the QSA flag instead of appending the query explicitly:
RewriteCond $1 !=control
RewriteRule ^([^/]+)/([^/]+)$ /pages/index.php?language=$1&page=$2 [L,QSA]
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论