Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 文件名中有两个句点的htaccess正则表达式_Regex_.htaccess - Fatal编程技术网

Regex 文件名中有两个句点的htaccess正则表达式

Regex 文件名中有两个句点的htaccess正则表达式,regex,.htaccess,Regex,.htaccess,我有一个当前表达式,它将site.com/index.php转换为site.com/index RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^\.]+)$ $1.php [NC,L] 我需要让它接受包含两个句点的文件名,比如site.com/core.index.php到site.com/core.index RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^([^\.]+)$ $1.php

我有一个当前表达式,它将
site.com/index.php
转换为
site.com/index

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
我需要让它接受包含两个句点的文件名,比如
site.com/core.index.php
site.com/core.index

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
任何帮助都将不胜感激

regex
^(.*)(?匹配每个不以“.php”结尾的地址,所以

RewriteRule^(.*)(?

可以。不过我不太熟悉重写规则。

使用这个正则表达式
^[\w\d]*\.[\w\d]*\/[\w\d]*\.[\w\d]*.[\w\d]*.

还提供了更简单的解决方案:

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f   # We don`t have such file (includes !-d)
RewriteRule ^(.*)$ $1.php [NC,L]     # Just add .php to the end

尝试
RewriteRule^(+)(\...-.\.]+)?$$1.php[NC,L]
我想
index.php
不应该重定向到
index.php.php
?为了避免这种情况,我们应该使用!-f而不是!-d这个解决方案没有第一个和第三个有用。它就像硬编码的东西,并不总是能够捕获所有可能的选项。