helmsui
helmsui

Reputation: 23

.htaccess Redirect Without The Question Mark

I am looking to redirect the URL http://www.example.com/user_pages/home_0.shtml?page=Home to http://www.example.com/. I have it redirecting to http://www.example.com/? using the following RedirectMatch:

RedirectMatch 301 ^/user_pages/home_0.shtml http://www.example.com/?

I was hoping that someone could help me figure out how to remove the trailing question mark. I understand that is the way I have it setup but that is the farthest I could get to matching what I need.

Secondary question but I think it falls in line with what I am doing here. I have the following RedirectMatch setup:

RedirectMatch 301 ^/user_pages/contactus_0.shtml http://www.example.com/help.php?section=contactus&mode=update

I am attempting to redirect http://www.example.com/user_pages/contactus_0.shtml?page=Contact%20Us to http://www.example.com/help.php?section=contactus&mode=update but I end up with http://www.example.com/help.php?section=contactus/user_pages/contactus_0.shtmlmode=update. I understand this is caused by the additional query string but I am at a lose on how to fix. Any help is appreciated.

Upvotes: 2

Views: 1014

Answers (1)

Felipe Alameda A
Felipe Alameda A

Reputation: 11799

One way to remove the ? of the query is like this:

RewriteEngine On
#Test for a query with `page=`
RewriteCond %{QUERY_STRING} ^page=.*$   
RewriteRule .* http://www.example.com? [L,R=301]

The last ? will remove the query including ?

As for the last part of the question, please check my comment.

Upvotes: 1

Related Questions