简体   繁体   English

意外的.htaccess行为

[英]Unexpected .htaccess behaviour

Having issues with .htaccess file - all I'm wanting to do is remove .php extensions, which is usually no problem. .htaccess文件有问题-我要做的就是删除.php扩展名,这通常没有问题。 I'm specifically wanting to only rewrite URLs containing alpha characters only (hence the capture group). 我特别想只重写仅包含字母字符的URL(因此捕获组)。

Rule: 规则:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]+)?$ /$1.php

</IfModule>

The rule works only on URLs that should return a 404 - ie, if I request mydomain.com/somegarbagestring, I get a 404, mydomain.com/somegarbagestring.php was not found on this server. 该规则仅在应返回404的URL上起作用-即,如果我请求mydomain.com/somegarbagestring,则得到404,在此服务器上找不到mydomain.com/somegarbagestring.php。 The 404 is expected, and the requested domain includes the .php extension, as it should 预期为404,并且所请求的域应包含.php扩展名

If I request a genuine URL - ie mydomain.com/thisisarealpage, the requested page does not include the .php extension. 如果我请求一个真实的URL-即mydomain.com/thisisarealpage,则请求的页面不包含.php扩展名。

Any ideas would be great. 任何想法都很棒。

并且....我发布问题后,立即找到了解决方案:

Options +Indexes +FollowSymLinks -MultiViews

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM