Jump to content

Hide PHP extension


dhope

Recommended Posts

Hi,

 

I currently have the following code in my .htaccess to remove the .php extension from my files.

 

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^(.*)$ $1.php

 

How would I change this so that "www.mydomain.com/services" becomes "www.mydomain.com/page/services"

 

I'm not really that clued up on mod_rewrite, please can someone point me in the right direction.

 

Thank you :)

Link to comment
https://forums.phpfreaks.com/topic/235353-hide-php-extension/
Share on other sites

Not sure what you want to do here.

 

Do you want  www.mydomain.com/services to be redirected to www.mydomain.com/pages/services and then have www.mydomain.com/pages/services call www.mydomain.com/services.php?

 

Or just have www.mydomain.com/services call www.mydomain.com/pages/services.php

Link to comment
https://forums.phpfreaks.com/topic/235353-hide-php-extension/#findComment-1209475
Share on other sites

Not really. You should start your links with a / that way your links will always load from the root of your site. Otherwise when you go to mydomain.com/pages/services your web browser will try to load your images/css files from mydomain.com/pages/services

Link to comment
https://forums.phpfreaks.com/topic/235353-hide-php-extension/#findComment-1209490
Share on other sites

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.