.htaccess添加新文件

时间:2012-04-24 18:16:35

标签: .htaccess

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /homepage/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /homepage/index.php [L]
</IfModule>

这是我的.htaccess代码。我在homepage / test.php中创建了新文件,当我从浏览器访问它时会出现访问错误,
 i have tried by replacing index.php with test.php but it still not working
有人可以解释一下这段代码是如何工作的,为什么我的代码不起作用。

i have deleted .htaccess but its still not working. What else file it can be.

1 个答案:

答案 0 :(得分:0)

更改

RewriteRule . /homepage/index.php [L]

为:

RewriteRule (.+) /homepage/index.php?page=$1 [L]

P.S。为此,index.php需要监听$ _GET ['page']并加载适当的资源。

编辑:不使用“?page = $ 1”,您的代码将只显示非文件或目录的所有请求的索引页。我不确定这是不是你想要的。