如何删除htaccess的URL参数 [英] how to remove url parameters in htaccess
问题描述
我不喜欢添加URL参数codigniter网站 例如mysite.com/page/value是好的,但 mysite.com/page/value?url=parameters是坏的。
I have a codigniter site which does not like added url parameters for example mysite.com/page/value is good but mysite.com/page/value?url=parameters is bad.
谷歌广告运动附加URL参数进行跟踪,我想摆脱这些对于调用codeigniter。 (我知道有几个方法可以做到这一点在codeigniter,但我想这样做htaccess的水平)
Google ads campaigns attach url parameter for tracking, I want to get rid of these for the call to Codeigniter. (I know there are several ways to do it in codeigniter but I want to do it in htaccess level)
我的htaccess是:
My htaccess is :
<IfModule mod_rewrite.c>
RewriteEngine On
# This is different between local host and production server!!!
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
我应该如何改变它,使之忽略的URL参数,但仍接受mysite的/ A / B /网址?
How should I change it to make it ignore url parameters but still accept mysite/a/b/ urls?
推荐答案
这应该可以删除任何查询字符串:
This should remove any query string:
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) $1?
这篇关于如何删除htaccess的URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!