使用mod_rewrite清除网址有问题

时间:2013-06-28 16:38:21

标签: .htaccess

我的.htacess文件有问题。

此代码适用于干净的网址。

RewriteRule ^([a-z]+)$ $1.php [L]
RewriteRule ^([a-z]+)/$ $1.php [L]

但是我所包含的文件没有被包含,因为.htaccess文件使浏览器看起来错误。例如,如果我在页面index/link/上并且我在文件夹root/includes中添加,则会查找文件夹root/link/includes

基本上它会在链接中添加一个不必要的步骤。

我希望有人了解我的问题并知道解决方案。

1 个答案:

答案 0 :(得分:1)

包含文件时,只需执行include __DIR__."/myfile.php";

即可

__DIR__用于当前文件目录,因此您可以包含RELATIVE到该ABSOLUTE路径的文件。例如include __DIR__."/../../some_other_file.php";