Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
Regex 将显示的URL更改为显示index.php而不是其他两个文件名_Regex_Url_Mod Rewrite_Url Rewriting_Rewrite - Fatal编程技术网

Regex 将显示的URL更改为显示index.php而不是其他两个文件名

Regex 将显示的URL更改为显示index.php而不是其他两个文件名,regex,url,mod-rewrite,url-rewriting,rewrite,Regex,Url,Mod Rewrite,Url Rewriting,Rewrite,我真的不喜欢正则表达式,我很难为我的网站设置规则 我有两个索引文件,分别名为index-pc.php和index-mob.php,我希望能够隐藏文件名的-pc/-mob部分。我应该使用哪种语法来执行此操作 我目前的规则是: RewriteEngine On RewriteRule ^index-(pc|mob)\.php$ index.php [L] 但这条规则不起作用。我错过了什么 谢谢。正则表达式似乎是正确的。您是否已启用.htaccess?如果没有,请打开httpd.co

我真的不喜欢正则表达式,我很难为我的网站设置规则

我有两个索引文件,分别名为index-pc.php和index-mob.php,我希望能够隐藏文件名的-pc/-mob部分。我应该使用哪种语法来执行此操作

我目前的规则是:

RewriteEngine On    
RewriteRule ^index-(pc|mob)\.php$ index.php [L]    
但这条规则不起作用。我错过了什么


谢谢。

正则表达式似乎是正确的。您是否已启用.htaccess?如果没有,请打开httpd.conf并进行更改

<Directory />
  ....
  AllowOverride None
</Directory>


谢谢你的回答。这与此无关,只是与我的.htaccess中的错误顺序有关,但我的问题是现在修改了一个重定向,然后它就不起作用了。这导致了404错误…实际上那里没有index.php文件,我只想显示一个替换名称来隐藏地址中的-pcor-mob部分。
<Directory />
  ....
  AllowOverride All
</Directory>