Jump to content

Remove .php File Extensions


unemployment

Recommended Posts

This is usually done in the .htaccess with mod_rewrite, we have a section for that, I'll move you there.

 

Thanks Maq.  I'm a bit lost with how to do this as a mod_rewrite.  I also really don't want to have to rename my links since my application is almost fully built. 

I also really don't want to have to rename my links since my application is almost fully built. 

 

If you want your links to not contain a file extension, you have to remove the file extension. That's all there is too it I'm afraid. All mod_rewrite does is intercepts incoming requests and serves up a specific resource, which you configure based on various patterns. For example, if your site uses php files you could use something like the following (quick example, could be typos)...

 

RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteRule ^[^.]+$ /%{REQUEST_URI}.php [L]

 

...this will take all requests to the server for files that don't exist and attempt to serve up a file with that name. So let's say somebody request http://www.domain.com/contact then it would attempt to serve up the file http://www.domain.com/contact.php.

Does anyone know the impact this has on SEO?  I have successfully redirected links to cleaner looking urls, but now the file can be accessed in two place.

 

for example you can go to mysite.com/contact and mysite.com/contact.php

 

I really don't want both accessible.  Any way to force a page load of contact.php to go to just contact?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.