Reputation: 14477
In Problem detecting empty REQUEST_URI with Apache mod_rewrite , its mentioned we can use
RewriteCond %{REQUEST_URI} ^.$
or
RewriteCond %{REQUEST_URI} "^/$"
I need to check if its not empty, then redirect it to an empty one(ignore all the string after HTTP_HOST).
I tried
RewriteCond %{REQUEST_URI} !"^/$"
RewriteRule .* http://%{HTTP_HOST} [L,R=301]
but not work. It just caused an endless loop.
Also I tried RewriteCond %{REQUEST_URI} !^/$
also RewriteCond %{REQUEST_URI} !^\/$
also RewriteCond %{REQUEST_URI} "!^/$"
also RewriteCond %{REQUEST_URI} "!^\/$"
Upvotes: 1
Views: 2925
Reputation: 987
How about this:
RewriteRule ^/.+$ http://%{HTTP_HOST} [L,R=301]
Upvotes: 1