Click here to Skip to main content
15,878,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I've been working in a web site for some time and I would like to remove the PHP extensions in all the existing pages.

I'm worried about loosing the current SEO and doing something wrong... I don't want to generate duplicates or similar...

Which would be the right way?

I can alter all the links returned by my database to exclude the PHP extension and I could work with the HTACCESS file, but how should I do it?

As always thank you in advance! :thumbsup:

What I have tried:

Seeing different approaches in the Internet doesn't help, plenty of them are simply not working (or I don't know how to implement them even they have only two or three code lines). :(

i.e.:
PHP
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Setting this into the htaccess file has not had any result.
Posted
Updated 5-Mar-17 19:43pm
v2

1 solution

If you want to remove an extension that points to an endpoint, and the old endpoint is now dead, set up a 302 route to a page that relates and the link will organically update with search engines.
 
Share this answer
 
Comments
Joan M 5-Mar-17 7:17am    
But... I would like to remove the extensions without modifying the files... is that possible?

The idea is not to show the extension only.

The 302 rules would allow me to change all files one by one. But is that the way?

Thank you!
Graeme_Grant 5-Mar-17 7:29am    
I answered the SEO part of the question. The content and quality of inbound links to the new/exist page will determine what will happen with the SEO ranking. If it is a dead link, then it will affect your SEO negatively. To what degree I can't say but if you have a large number of dead or missing links, then I would suspect quick a bit.

I would like to answer the php part but alas I am not a php dev. Someone else may be able to help you with that.
Joan M 5-Mar-17 8:37am    
Wonderful! thank you. That's clear now.
If you don't mind I'll accept your answer once I've received help from someone about the PHP part.

Thank you very much Graeme_Grant!
Graeme_Grant 5-Mar-17 8:44am    
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900