htaccess无需查询字符串即可重定向到同一页面 [英] htaccess redirect to the same page without querystring

查看:118
本文介绍了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[^]


这篇关于htaccess无需查询字符串即可重定向到同一页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆