Jump to content

Hiding .php Extension


Recommended Posts

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 me

i will thankful for this . .

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...