Mhari Posted May 29, 2016 Posted May 29, 2016 I have tried many codes in .htaccess file that will make file extension hidden. But all of that is not working as expected. When i have saved the code, and i am trying to access it and the result either error 500 or redirecting to index page again.Please anyone help mei will thankful for this . .
nyten Posted May 29, 2016 Posted May 29, 2016 Try this code: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] This shows .php files without extension. When accessing the correct file you can for example block the access or redirect it.Which code did you use?
Byron Posted May 29, 2016 Posted May 29, 2016 You can use MultiViews in your .htaccess file like this: Options +MultiViews http://stackoverflow.com/questions/25423141/what-exactly-does-the-the-multiviews-options-in-htaccess http://bybyron.net/test/multi/pooman http://bybyron.net/test/multi/pooman.php
Mhari Posted May 29, 2016 Author Posted May 29, 2016 I am sorry i can't replying sooner.Ok this problem was solved. Simply just adding multyviewsthank you so much guys!Its working perfectly!
Mhari Posted May 30, 2016 Author Posted May 30, 2016 Hi,but please can you tell me how to redirect users to the file which its extension was hidden?Example, if user visit http://my.site/test.php, they will be redirected to http://my.site/test ? The one thing i am afraid about that maybe search engines will indexing both url then marking my site as spam or whatever.Please help,,thank you..
Ryan Zimmerman Posted June 3, 2016 Posted June 3, 2016 The one thing i am afraid about that maybe search engines will indexing both url then marking my site as spam or whatever. The most foolproof solution for that is the <link rel="canonical"> tag. Read more at https://support.google.com/webmasters/answer/139066?hl=en. In your case you would set the canonical url to the url without the extension.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now