Mod rewrite 重写规则问题
是否有任何方法可以使用RewriteRule显示这些链接: /articles\u history.php /articles\u geography.php 作为 /articles/history.html /articles/geography.html 我在我的根目录上创建了一个.htacesss文件,我想知道在.htaccess文件中放置某种代码是否可以实现上述功能。是的Mod rewrite 重写规则问题,mod-rewrite,url-rewriting,Mod Rewrite,Url Rewriting,是否有任何方法可以使用RewriteRule显示这些链接: /articles\u history.php /articles\u geography.php 作为 /articles/history.html /articles/geography.html 我在我的根目录上创建了一个.htacesss文件,我想知道在.htaccess文件中放置某种代码是否可以实现上述功能。是的 RewriteEngine On RewriteRule /articles/(.+)\.html /articl
RewriteEngine On
RewriteRule /articles/(.+)\.html /articles_$1.php [L,QSA]
看
除了RewriteRule,您通常还需要通过RewriteEngine指令打开重写引擎。在.htaccess中尝试以下操作:
RewriteEngine on
RewriteRule ^article/([^/]+)\.html$ articles_$1.php [L]
对于任意输入:
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)\.html$ $1_$2.php [L]
@NegativeRecack-是的,PHP文件的直接URL仍然可以正常工作。实际上,我希望我的浏览器显示:如地址栏上所示。就这样!我将.htaccess文件放在“yo”文件夹中。我现在到底要做什么?感谢您的帮助:)@negativerack-现在只需转到
localhost/articles/history.html
如果您想将/yo/
放在前面,您需要修改重写规则