colap Posted April 2, 2017 Share Posted April 2, 2017 I tried this in .htaccess: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule "^(.+)" "/" It works when the url looks like "http://localhost/project/xyz" , it redirects to "http://localhost/project/". But the url can be "http://localhost/project/xyz?id=5&t=abc", then it redirects to index page but the parameter is still there in url "http://localhost/project/?id=5&t=abc" , how can I remove all those parameters after redirecting to index page? Link to comment Share on other sites More sharing options...
kicken Posted April 2, 2017 Share Posted April 2, 2017 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. Link to comment Share on other sites More sharing options...
Jacques1 Posted April 2, 2017 Share Posted April 2, 2017 Silently redirecting the user when the URL is erroneous is usually a very bad idea and can cause a lot of confusion. Errors should in fact be reported with a proper status code, so that the user can fix them or at least knows that there's a problem. There's a reason why the 404 code exists. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.