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?
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
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.
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):
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!)
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.