Php 简单Htaccess正则表达式
我在文件夹中的.htaccess文件中有以下代码Php 简单Htaccess正则表达式,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我在文件夹中的.htaccess文件中有以下代码 http://localhost/modrewrite/test/ RewriteCond %{REQUEST_URI} ^modrewrite/.*$ RewriteRule b.html [L] 我所要做的就是每当我转到上面文件夹中的index.php时,我希望它重定向到b.html。我知道这可以通过使用 RewriteEngine on RewriteRule index.php b.html [L] 但是我想使用RewriteCon
http://localhost/modrewrite/test/
RewriteCond %{REQUEST_URI} ^modrewrite/.*$
RewriteRule b.html [L]
我所要做的就是每当我转到上面文件夹中的index.php时,我希望它重定向到b.html。我知道这可以通过使用
RewriteEngine on
RewriteRule index.php b.html [L]
但是我想使用RewriteCond和%{REQUEST_URI}来看看它实际上是如何工作的。谢谢。“我想使用RewriteCond和%{REQUEST\u URI}
”
您可以尝试以下规则:
RewriteEngine on
RewriteCond %{REQUEST_URI} index\.php
RewriteRule ^ b.html [L]
虽然我会建议其他规则更干净,即
RewriteRule ^index\.php$ b.html [L,NC]
参考:“我想使用RewriteCond和%{REQUEST\u URI}
”
您可以尝试以下规则:
RewriteEngine on
RewriteCond %{REQUEST_URI} index\.php
RewriteRule ^ b.html [L]
虽然我会建议其他规则更干净,即
RewriteRule ^index\.php$ b.html [L,NC]
参考: