WAMP 使用 RewriteRule 自动将 .php 扩展名添加到文件
WAMP automatically adds .php extension to file with RewriteRule
我正在尝试使用 apache .htaccess(重写)重写我的 url,如下所示:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)/?$ index.php?url= [QSA,L]
我的小项目结构是:
- .htaccess
- index.php
- test.php
一切正常,无论我在 $_GET["url"] 变量中的“/”之后键入什么。但是只要我输入域。com/index,它就会以某种方式自动将 .php 扩展名添加到我的 url 并留下我的 $_GET["url" ]为空。当我尝试域时同样的故事。com/test:它转到 test.php 而不是重写到 domain.com/url=test.
最奇怪的是,在 000webhost.com 上一切正常!当我上传相同的文件时,它会在我的 $_GET[[=45] 中显示 index 和 test =]]变量。
希望有人能帮助我!
格拉茨
这是因为启用了Multiviews
选项。删除这个解决了这个问题。
我正在尝试使用 apache .htaccess(重写)重写我的 url,如下所示:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)/?$ index.php?url= [QSA,L]
我的小项目结构是:
- .htaccess
- index.php
- test.php
一切正常,无论我在 $_GET["url"] 变量中的“/”之后键入什么。但是只要我输入域。com/index,它就会以某种方式自动将 .php 扩展名添加到我的 url 并留下我的 $_GET["url" ]为空。当我尝试域时同样的故事。com/test:它转到 test.php 而不是重写到 domain.com/url=test.
最奇怪的是,在 000webhost.com 上一切正常!当我上传相同的文件时,它会在我的 $_GET[[=45] 中显示 index 和 test =]]变量。
希望有人能帮助我!
格拉茨
这是因为启用了Multiviews
选项。删除这个解决了这个问题。