从Rootdomain删除查询字符串 [英] Remove Query String from Rootdomain

查看:116
本文介绍了从Rootdomain删除查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,有一个简单的重定向一(子)域或文件夹到另一个我可以摆脱一个字符串,像这样

I know with a simple redirect one (Sub-)Domain or Folder to another i can get rid of a string like this

RewriteEngine On
RewriteRule (.*) http://www.domain.tld/? [R=301,L]

我知道如何摆脱它时,它是一个简单的文件了。

I know how to get rid of it when it is a simple file too.

但是,当涉及到Rootdomain本身( HTTP://domain.tld/ Stringwhatsoever )我在这里的损失。我最后一次尝试使用重定向我用重定向各地文件和文件夹的修改版本和工作pretty的很好,也去掉了查询,但它在一个重定向错误结束了。

But when it comes to the Rootdomain itself (http://domain.tld/?Stringwhatsoever), i am at a loss here. My last try used a modified version of a redirect I used to redirect files and folders around and that worked pretty nicely and also removed the query, but it ended up in a redirection error.

RewriteRule ^ http://domain.tld/? [L,NC,R=301]

所以,我不知道如何在网址摆脱查询字符串不破坏它。

So i have no clue how to get rid of Query Strings at urls without breaking it.

推荐答案

试试这个:

RewriteEngine On
RewriteCond %{THE_REQUEST} /\?([^\s]+) [NC] 
RewriteRule ^$ http://domain.com/? [NC,R,L]

RewriteEngine On
RewriteCond %{QUERY_STRING} (.+) [NC] 
RewriteRule ^$ http://domain.com/? [NC,R,L]

参考:

- https://wiki.apache.org/httpd/RewriteQueryString

这篇关于从Rootdomain删除查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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