带空格的.htaccess问题

时间:2014-03-08 21:58:43

标签: php apache .htaccess mod-rewrite

我有这个.htaccess,它应该隐藏.php,但它可能有问题这个网址 www.webpage.com/index.php?msg=some msg with spaces
可以修复吗?


RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

编辑:
www.mysite.com/message.php?msg=You%20are%20logged%20in%20your%20rid%20is:8
在页面中我刚写了msg的内容:$ _GET [“msg”]:

  

你登录的是你的:DOCTYPE htmlhtmlheadmeta charsetutf8 if   IEscript   srchttp:html5shiv.googlecode.comsvntrunkhtml5.jsscriptendiftitle ...


它之后写了html文件,而不是摆脱那里传递的形式会话。

2 个答案:

答案 0 :(得分:0)

使用QSA =查询字符串追加。

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L, QSA]

答案 1 :(得分:0)

您的第一条规则中需要NE(无逃避)标志:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]