[英].htaccess url rewriting not working
我在我的网站中将URL重写用于一个简单的便笺应用程序。 所有的东西都在/notes/
目录下。 .htaccess
内容是,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?filename=$1 [L]
而要访问的网址是
http://localhost/notes/test.txt
我想获取test.txt作为filename
变量的值。
但是当我使用echo $_GET['filename'];
在index.php
,它显示index.php
而不是显示test.txt
。
在这里, test.txt
不是真实的文本文件,而是filename
变量的值。
我认为问题在于您的“ index.php?filename = test.txt” URL也正在由您的规则处理和重写。 您可能需要更改.htaccess
代码以停止引用已被重写的文件:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?filename=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.