我目前有以下 .htaccess 。
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/abc/php.ini
</IfModule>
RewriteEngine on
RewriteCond $1 !^(index\.php|media|css|js|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
AuthType Basic
AuthName "Está dominado!!"
AuthUserFile "/home/abc/.htpasswds/public_html/passwd"
require valid-user
现在的问题是,如果在 / 之后找到任何查询字符串,我想删除该查询字符串。
所以:
如果我们有:
http://www.abc.com/?这里有什么234
它应该重定向到:
http://www.abc.com/
如果我们有:
http://www.abc.com/something/?id212
重定向至:
http://www.abc.com/something/
更新:
我试过这个:
TRY A)
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule .* /index.php/ [L,QSA]
希望 ^(.*)$ 将允许查询字符串上的任何内容......
我也尝试过这个:
TRY B)
RewriteCond 上的 RewriteEngine $1
!^(index.php|媒体|css|js|图像|robots.txt)
RewriteCond %{QUERY_STRING} ^(.)$
重写规则 ^(.)$ http://abc.com/ [L]
这将返回 500 内部服务器错误。
TRY C)
RewriteEngine on
RewriteCond $1 !^(index\.php|media|css|js|images|robots\.txt)
#RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ http://abc.com/ [R=302,L]
我承认我对这个 .htaccess 语法有点迷失。
TRY D)
RewriteEngine on
RewriteCond $1 !^(index\.php|media|css|js|images|robots\.txt)
RewriteCond %{REQUEST_URI} !^/
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ http://abc.com/ [R=302,L]
请指教,
模模