2015-11-25 84 views
1

相同的名称我如何使它所以这样的:文件夹和php文件与网站

www.example.com/product 

将指向此文件:/product.php但这:

www.example.com/product/thing.php 

将指向这个目录:/product/thing.php

我在我的.htaccess这些重写规则:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.php [NC,L] 

它让这样的:

www.example.com/product.php 

进入这个:

www.example.com/product 
+0

问题是什么?你试图使用哪个网址?你得到什么错误? – anubhava

+0

看到我的回答http://stackoverflow.com/a/33319570/5397119 –

回答

0

我发现你可以做一些几乎一样好的事情。

www.example.com/product 

变为:

www.example.com/product/ 

如果添加了 '的index.php' 或在Web服务器上的产品目录 '的index.html'。所以路径变成了product/index.php,并且url将如下所示:

www.example.com/product/ 
2

切换DirectorySlash

DirectorySlash Off 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^.]+)$ $1.php [NC,L] 
+0

不幸它没有工作:( –