我想用.htaccess文件重写我的URL。
如果我的URL喜欢:
/test/controller/hello
我想将其重写为:
/test/controller.php/hello
我也想添加一个RewriteCond
来说 (hello|hey|hi)
当我不希望它成为这3个时,允许你好。
我对3种可能性的状况是
RewriteCond %{REQUEST_URI} !^/test/controller/(hey|hello|hi)$
RewriteRule . ^/test/controller/hello$
是吗?
您可以使用:
RewriteCond %{REQUEST_URI} /(hey|hello|hi)$
RewriteRule ^test/([^/.]+)/(.+)$ /test/$1.php/$2 [NC,L]
条件测试如果嘿或 hello 或 hi 在URI的末尾。如果conditon为true,则规则重写 test/foo/hello | hi | hie | hey to test/foo.php/hello | hi | hi | hie 。