这就是我的htaccess文件现在的样子:
RewriteEngine On
RewriteRule ^([\sa-zA-Z0-9_-]+)$ view.php?folder=$1
RewriteRule ^([\sa-zA-Z0-9_-]+)/$ view.php?folder=$1
RewriteRule ^([\sa-zA-Z0-9_-]+)\.html$ view.php?page=$1
它接受网址为:
http://localhost/new.html to view.php?page=new
http://localhost/something to view.php?folder=something
http://localhost/something/ to view.php?folder=something
但它不适用于url:
http://localhost/something%20else
http://localhost/something%20else/
应为view.php?folder=something%20else
答案 0 :(得分:1)
According to this answer你应该在你的htaccess重写上使用url重写标志。
(以下链接的无耻引用:)
尝试添加
B
重写标记。这个标志告诉mod_rewrite逃脱 反向引用,documentation says this:_rewrite必须在映射URL之前对其进行unescape,因此反向引用将在应用它们时未转义。使用B标志, 反向引用中的非字母数字字符将被转义。