I have this page.
maximalearning.hardsoft.xyz
What should I do so that every time a user tries to navigate in this way...
maximalearning.hardsoft.xyz/index.php?id=start
It redirects to index.php and so on with the rest of the pages. But it is if there is something after the ".php" not just a "?variable=value"
Thanks.
As indicated in the comments, having an Apache server, you can use the file
.htaccess
to define redirects. So what you are looking for would be something like this:The part about activating the redirects module doesn't require much explanation, but I think more information is needed in the other two lines:
RewriteCond %{QUERY_STRING} .
: this line is a condition, the next line will only be executed if the requested URL includes a query string (the ?name=value part)RewriteRule ^(.*)$ $1? [L,R=301]
: this line is more interesting, basically what it says is:^(.*)$
)$1
)?
after$1
; without the?
, the query string will remain in the URL)L
)R=301
; without this signal, the redirection would be made but no change would be seen in the address bar).If you don't want to use it
.htaccess
, you could do a similar redirect from PHP (although it would be less efficient) by adding this little script to the top of all PHP files that you want to remove their query string :