htaccess如何重写url如果url存在字符串
问题描述:
我想用htaccess重写我的url,当URL包含某个字符串时。htaccess如何重写url如果url存在字符串
例子:
My url : example.com/information
当 “信息” 是在我的网址,我要重写我的information.php文件的文件。 希望任何人都可以帮助我。
答
试试这个:
RewriteCond %{REQUEST_URI} !/information\.php$
RewriteRule information information.php [L]
此规则将改写包含在URL路径“信息”在同一个目录下information.php文件的任何请求。
https://stackoverflow.com/a/4026967/6124528 – Manav
[与htaccess的删除PHP扩展(的可能的复制https://stackoverflow.com/questions/4026021/remove-php -extension与 - htaccess的) – Croises