htaccess无需查询字符串即可重定向到同一页面
大家好,
我遇到了htaccess问题,希望您能为我提供帮助:
当我在URL中有一个querystring参数时,我必须重定向到没有这些参数的同一页面.
示例:
http://sos-med.com/en/our-offices/endokrinologiya.html ?print = 1& tmpl = component
必须重定向到:
http://sos-med.com/en/our-offices/endokrinologiya.html
Htaccess文件的代码是什么:
1.从所有参数清除URL时,重定向到同一页面
2.仅在URL中存在参数"print"时执行此操作
问候,
Vitaly.
Hi guys,
I got an htaccess question, hopefully you could help me out:
When I have a querystring parameters in URL, I have to make a redirection to the same page without these parameters.
Example:
http://sos-med.com/en/our-offices/endokrinologiya.html?print=1&tmpl=component
must redirect to:
http://sos-med.com/en/our-offices/endokrinologiya.html
What is the code for Htaccess file for:
1. Redirect to the same page while cleaning URL from all parameters
2. Doing this only if parameter "print" exist in URL
Regards,
Vitaly.
尝试:
Try:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^*print=*
[NC] RewriteRule ^(.*)
[NC] RewriteRule ^(.*)
%{REQUEST_URI}?
%{REQUEST_URI}?
我自己还没有尝试过,但是应该可以.如果没有,请在此处查看文档:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html [ ^ ]
I haven''t tried it myself, but that should work. If not, check out the documentation here:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html[^]