I want to hide extensions on my webpage using the .htaccess file.I have managed to do it by using this code;RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^([^\.]+)$ $1.php [NC,L]So when I visit mysite.com/index it shows my index.php. That's fine but I want to block visitors from visiting mysite.com/index.php so it should be redirected to mysite.com/indexI think I have found a way to do that. However, I will be using querystrings on my webpage. There will be some pages which I will need to carry the variables via GET method.Normally a link with an id variable is like this; index.php?id=xxHowever, if I redirect /index.php to /index my variables will be gone. So I want the urls to seem like this when carrying a variable mysite.com/index?id=xxThe extension will be PHP always. But I want this system work in all pages with all variables. I am not sure how many pages and variables there will be so do I have to write a rule in htacces for each of them or can I define a general rule? So it will be like thisExamples:index.php?id=xx will be index?id=xxindex.php?page=xx will be index?page=xxusers.php?uid=xx will be users?uid=xxnews.php?nid=xx will be news?nid=xxThis could probably be achieved using .htaccess file but I don't know, how can I do that.P.S. Although I am pretty good at PHP, I don't know anything about creating a rule for htaccess file I just use the codes I find on the internet.
Hiding and redirecting extensions on my webpage
php;htaccess;mod rewrite;url rewriting;query string