Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mod rewrite 重写规则问题_Mod Rewrite_Url Rewriting - Fatal编程技术网

Mod rewrite 重写规则问题

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

是否有任何方法可以使用RewriteRule显示这些链接:

/articles\u history.php

/articles\u geography.php

作为

/articles/history.html

/articles/geography.html

我在我的根目录上创建了一个.htacesss文件,我想知道在.htaccess文件中放置某种代码是否可以实现上述功能。

是的

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/
放在前面,您需要修改重写规则