We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Still possible to remove the file extension from the PHP file?

How Do I?

SPC-Lesli's avatar
SPC-Lesli
30 posts
5 years ago
SPC-Lesli's avatar SPC-Lesli

Hi all,

I have used EE for quite a while. For legacy reasons, I want to leave the index.php file in the path…but a) it will be renamed from “index” to “such” and b) it will have the php file extension removed. My site will be on Apache, using PHP 7. The hosting control panel will be DirectAdmin. Web host is Hostmatters.

This was possible in EE versions 3 and earlier. Looking through the documentation for version 5, in preparation for upgrading. I see instructions for removing the index.php from the URLs totally, but that isn’t what I want to do.

Does anyone know if this is still possible?

? 1
       
aquicksharp's avatar
aquicksharp
28 posts
5 years ago
aquicksharp's avatar aquicksharp

Hi I have done this before in wordpress by changing index.php in .htaccess So for example this is a standard .htaccess setup for wordpress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

If you want to change to index.php to site.php just substitute it in

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^site\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site.php [L]
</IfModule>

This works with wordpress, I have never tried it with EE but its worth a try

       
SPC-Lesli's avatar
SPC-Lesli
30 posts
5 years ago
SPC-Lesli's avatar SPC-Lesli

Thanks @aquicksharp. I am hoping to find a solution that won’t require editing the EE files themselves (and it seems that this is a DirectAdmin issue, at least in part) but I’ll keep your suggestion in reserve.

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
5 years ago
Robin Sowell's avatar Robin Sowell

You can set it to be whatever you want in EE- so nothing or just site. But you need to get the server to treat ‘site’ as php. That I don’t know how to do and my recommendation is to just remove it entirely. But if you were doing it before, you should be able to use the same approach in v5.

       
Henry the II (and a 1/2)'s avatar
Henry the II (and a 1/2)
9 posts
5 years ago
Henry the II (and a 1/2)'s avatar Henry the II (and a 1/2)

I have a site hosted by Hosting Matters, and I have been doing exactly this for quite a while, even on a fully upgraded EE (currently 5.3.0)

I am doing this for both the frontend file (index.php) and the backend one (admin.php) and it works flawlessly - I even upgraded that site from a very old EE 2.11 to the latest 5.x with that setup.

As Robin Sowell wrote, you have to ‘get the server to treat “site” as php’, and that is done with a very simple instruction in your site’s root .htaccess file.

Here’s how it’s done (I am assuming you have a shared hosting plan):

  • rename your file(s): index.php -> site (and if you like, admin.php -> anything-you-want)
  • add the following instruction in the root .htaccess (or in your EE installation’s root directory, if you’ve installed it under anything else than /home/your.HM.account.name/public_html/)

this is the example with ‘site’:

<Files site>

    ForceType application/x-httpd-ea-php71

  </Files>

Now there is a trick: you will need to adjust the actual instruction depending on which HM server you are, even if the AMP (Apache, MySQL, PHP) versions are (seemingly) identical, as the default PHP version in use in your account may differ from server to server. I found that out the hard way, as my site was moved around when they switched servers (notably during their migration from cPanel to DirectAdmin), and the site suddenly ‘stopped working’.

The good news is that you can try different instructions without breaking anything permanently. Here’s what I went through on different server moves (I went through 3 server at Hosting Matters, and the following did work, each on a given server)

ForceType application/x-httpd-ea-php70

ForceType application/x-httpd-ea-php71

ForceType application/x-httpd-php

Simply try one after the other in your .htaccess, accessing your site in between until you find the one that works.

In last resort, don’t hesitate to open a ticket at Hosting Matters. it is still a friendly, human-sized operation (thank God) and they’ve always been very helpful, even with issues like these (hat tip to Annette & Stacy!)

       
SPC-Lesli's avatar
SPC-Lesli
30 posts
5 years ago
SPC-Lesli's avatar SPC-Lesli

Annette and Stacy are excellent!

Those last three commands look new to me, they’re something I haven’t tried yet. I’ll give those a whirl. Thank you!!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.