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这个解决方案没有第一个和第三个有用。它就像硬编码的东西,并不总是能够捕获所有可能的选项。