简体   繁体   中英

Unexpected .htaccess behaviour

Having issues with .htaccess file - all I'm wanting to do is remove .php extensions, which is usually no problem. I'm specifically wanting to only rewrite URLs containing alpha characters only (hence the capture group).

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. The 404 is expected, and the requested domain includes the .php extension, as it should

If I request a genuine URL - ie mydomain.com/thisisarealpage, the requested page does not include the .php extension.

Any ideas would be great.

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

Options +Indexes +FollowSymLinks -MultiViews

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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