rook
rook

Reputation: 67019

How can I use mod_rewrite to remove everything after the ? (question mark) in a URL?

How can I use mod_rewrite to remove everything after the ? (question mark) in a URL?

For instance:

http:// 127.0.0.1/ALL_FILES.php?test=1

after mod_rewrite:

http:// 127.0.0.1/ALL_FILES.php

For php this means that the $_GET super global will always be empty for all files on the system.

Thank you.

Upvotes: 1

Views: 1230

Answers (1)

zombat
zombat

Reputation: 94147

The following rule should take care of it (for all URLs on your site, as mentioned):

RewriteCond %{QUERY_STRING} .+
RewriteRule ^(.*)$ /$1? [R=301,L]

I must admit I'm a bit curious as to why you would want to do this... I don't think it has much SEO value, and you could just ignore the $_GET variables inside your scripts?

Upvotes: 1

Related Questions