AgA*_*AgA 3 regex apache .htaccess mod-rewrite joomla1.5
我无法删除一个 404 SEF 模块错误添加的 GET 参数。
我想删除“task=view”仅当它单独出现而不是与另一个参数一起出现时。
所以
www.mysite.com/1.html?task=view应该被重定向到www.mysite.com/1.html。
而www.mysite.com?task=view&view=article应该保持不变。
无论我使用哪个 RewriteRule,这个参数都不行。看起来它是在运行 index.php 时从任何环境变量生成的。
例如,这不起作用:
RewriteCond %{QUERY_STRING} ^task=view$ [NC]
RewriteRule (.*)task=view.* $1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)
这是我的 .htaccess 文件:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|.php|.html|.htm|.feed|.pdf|.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
Options -Indexes
Run Code Online (Sandbox Code Playgroud)
处理这种情况的方法是什么?
使用这个规则:
RewriteCond %{QUERY_STRING} ^task=view$ [NC]
RewriteRule ^(.*)$ $1? [R=301,L]
Run Code Online (Sandbox Code Playgroud)
?最后$1将删除任何现有的查询字符串。