I have the following .htaccess at present.
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/abc/php.ini
</IfModule>
RewriteEngine on
RewriteCond $1 !^(index\.php|media|css|js|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
AuthType Basic
AuthName "Está dominado!!"
AuthUserFile "/home/abc/.htpasswds/public_html/passwd"
require valid-user
Now the thing is, I would like to, if any query string is found after a / remove that query string.
So: If we have:
http://www.abc.com/?somethinghere234
It should redirect to:
http://www.abc.com/
If we have:
htpp://www.abc.com/something/?id212
Redirect to:
htpp://www.abc.com/something/
UPDATE: I've tried this:
TRY A)
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule .* /index.php/ [L,QSA]
Hopping that ^(.*)$ will allow anything on the query string...
I've also tried this:
TRY B)
RewriteEngine on RewriteCond $1 !^(index.php|media|css|js|images|robots.txt) RewriteCond %{QUERY_STRING} ^(.)$ RewriteRule ^(.)$ http://abc.com/ [L]
This returns a 500 internal server error.
TRY C)
RewriteEngine on
RewriteCond $1 !^(index\.php|media|css|js|images|robots\.txt)
#RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ http://abc.com/ [R=302,L]
I confess I'm kind of lost on this .htaccess sintax.
TRY D)
RewriteEngine on
RewriteCond $1 !^(index\.php|media|css|js|images|robots\.txt)
RewriteCond %{REQUEST_URI} !^/
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ http://abc.com/ [R=302,L]
Please advice, MEM
I wasn't sure from your description exactly what you were after, so you should keep or remove the second RewriteCond depending on your specific needs.
Possibly because you have QSA added on there - it means Query String Append.
The following should work:
From the Apache documentation:
EDIT (again): As external redirect (you may not even need the second RewriteCond if you don't have any query string at all in your application):
This will tell the client to request the same URI without query string.