使用.htaccess从目录中删除扩展名

时间:2013-04-26 15:13:41

标签: .htaccess

好。我知道这里有数百个问题要求同样的东西,但是所有提供的编辑代码都不适合我,仍然会抛出404,所以我希望有人能解决它,因为它已经杀了我整个上午。

这是基本结构。

public_html
-folder
-folder
-fhf
--index.php
--about.php

我的问题是如何将/fhf/index.php中的.php从/fhf/index文件夹中删除为/fhf/

我已经在这里尝试了几乎所有的代码块,这是我尝试过的,但它仍然无效。我将此.htaccess放在/fhf/文件夹中。

RewriteEngine On
RewriteBase /

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

所有这一切都是The requested URL /fhf/index was not found on this server.,我不知道出了什么问题。这可能是我忽略的一些愚蠢的错误。

所有帮助都是适用的。感谢

回答感谢faa和Answer

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
# Prevent loops
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.php  [NC]
# Map internally to the resource, showing the "pretty" URL in the address bar
RewriteRule  ^([^/]+)/([^/]+)/?   /$1/$2.php  [L,NC]

0 个答案:

没有答案