Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to redirect all urls starting with www.site.com/online/ to www.site.com

some examples of the files I'm trying to redirect are ...

www.site.com/online/folder1/folder2/folder3/?gdt=wbgMfFt9PVUKEwjiparBqM-kAhUMdoYKHW5GKa0QAhgBIAQw-PuCATgeUPj7ggFQpPmYD1CGra8PUIvr_xNQuOv_E1DU6IQbUIq23B5QsuXZIFD5uqqnAVCDrYrIAVCgy5HZAQ&slt=8&slr=5&lpt=2

my current condition is very simple and it is doing everything except for removing the parameter in the url.

RewriteRule ^online/(.*)  http://www.site.com [R=301,L]

right now this rule will redirect

www.site.com/online/folder1/folder2/folder3/?randomgetparameter=blablabla

to

www.site.com/?randomgetparameter=blablabla

instead of redirecting to

www.site.com
share|improve this question
add comment

1 Answer

From apache docs:

Modifying the Query String

By default, the query string is passed through unchanged. You can, however,
create URLs in the substitution string containing a query string part.
Simply use a question mark inside the substitution string to indicate that
the following text should be re-injected into the query string. When you want
to erase an existing query string, end the substitution string with just a
question mark. To combine new and old query strings, use the [QSA] flag.

So -- try: RewriteRule ^online/(.*) http://www.site.com/? [R=301,L]

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.