[updated March 2015] You will notice that this site which runs using WordPress that there is no index.php in the URL when you are directly addressing a page/post or when you are linking to other pages/posts. This can achieved using the following configuration.
There are two step 1’s, depending on whether you/your web provider is using Apache or Zeus scripting. To find out which server type are using (and loads of other information too, see Step 3 below).
Step 1: If your web server is using Zeus then:
Create a text file “rewrite.script” and add the content:
1 2 3 4 5 6 7 8 9 10 11 12 |
#Zeus webserver version of basic Wordpress mod_rewrite rules map path into SCRATCH:path from %{URL} look for file at %{SCRATCH:path} if exists then goto END look for dir at %{SCRATCH:path} if exists then goto END ##### FIX FOR LOGIN/FORGOTTEN PASSWORD/ADMIN ETC ##### match URL into $ with ^/wp-.*$ if matched then goto END ##### FIX TO ALLOW SEARCH TO WORK ##### match URL into $ with ^/(.*) set URL = /index.php/$1 |
to the file and place it in your “Web” directory (e.g., this is the naming format on Register365/Hosting365)
Step 1: If your web server is using Apache then:
As of 2014/15, most Register365 accounts now use Apache rather than Zeus. Modify your .htaccess file in the FTP root directory (i.e., the directory that you are placed in when you FRP to the site below “web”). It may already contain configuration information (that is the case for the first line below) and add the content between the # BEGIN WordPress and # END WordPress comments below:
1 2 3 4 5 6 7 8 9 |
AddHandler php56-script .php .php5 # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress |
Then upload the edited file it back to your FTP root directory. Remember that if you use the server tools to update the version of PHP that your account is using that you may have to make this change again.
Step 2: Changing your WordPress settings:
In the WordPress administrative interface, go into Settings->Permalinks and change the “Common Settings” to “Custom Structure” and enter:
1 |
http://derekmolloy.ie/%postname%/ |
or whatever other custom URL you are using. The important thing here is to remove the index.php from the URL.
Step 3. Finding out Server Information
The quickest way to find out detailed information about your server configuration is to create a script called info.php (or any_other_name.php) that contains the following line of code:
1 |
<!--?php phpinfo(); ?--> |
FTP this file to your server web directory and then use your web browser to call the script e.g. www.derekmolloy.ie/info.php (this link will not work for security reasons!). When you call the URL you will get an output such as in the figure below:
Towards the bottom of this long page you will find “PHP Variables” and one of the entries is the SERVER_NAME, which is typically either Apache or Zeus. In Chrome just use Ctrl-F and search for SERVER_NAME.
Derek
I have a quite a few websites built on wordpress with no problems concerning permalinks. However dublinaccommodation.ie is the first one hosted on register365 and I noticed the ‘index.php’ problem.
Yours was the first post I saw which mentioned a solution for Zeus.
I followed your instructions, created and uploaded a rewrite.script and changed to Custom Structure to /%postname%/ but I found that this caused ‘page not found’ on all pages except the homepage.
Any further ideas?
(I have reverted back to the default so you will not see the problem live)
Hi Eamon, I am actually using Register365, so I’m not sure why you are having a difficulty. The structure of my site is that everything is in the “web” directory, so the rewrite.script is there (i.e. in the same directory as index.php) and it has read access for all users (0664). Kind regards, Derek.
TTTTHHHAAANNNKKKKK YOU!!! That’s a really annoying headache out the window.
Have used this script before, Plesk and Zeus are difficult, remember to make a backup of your database just in case. Have got this script wrong in the past, and it causes headaches…..
Zeus version as above works…..Confirmed……
Derek,
I am having the same problem. I have copied the rewrite file up to the web folder which contains the index.php but when I change to custom permalink I get a lot of the page not found error. I’d really love some help as this has been causing me a problem for sometime and would like to get sorted.
Any advice.
Amadna
Hi,
For Eamon and Amanda, in case this is not fixed for you yet.
After uploading the new text file to the web folder, rename it removing the .txt at the end.
That should work following the rest of Dereks advice
Many thanks for this. I’m on a namesco server and had this problem. Now it’s gone, thanks to your recipe.
Thanks for that. Worked a treat. I always thought hosting365 relied on the .httaccess file. I had limited success with this in the past. Actually broke a site one day messing with it. The rewrite.script worked a treat.
Hi,
I have added the rewrite.script and uploaded it to the web directory in reg365 , it has removed index.php but all other pages is 404 please advise thanks
Delighted I found this. Worked 1st time. Thanks a million for posting.
Thank you for this. Worked a treat !
It worked perfectly on Register365, thanks a million!
Derek,
I followed your instruction but neither of the methods seem to be working. Is there anything different/slightly different for IIS? Thanks so much
Hi,
I would just like to say thank you for this. It really solved my problem with the annoying index.php stuff in my URLs.
Again, thank you so much.
Cheers!
Thanks Derek. Worked a treat for me.
The screen pass on the website is update123
I have followed you tutorial and It worked great I did however have to remove (.txt) from the rewrite.script.txt
Everything is working fine but the main domain address Ricedrivinglessons.ie is registering as a post and not the homepage, Any suggestions? The domain Ricedrivinglessons.ie/home is of course the homepage.
I feel its a theme option but I thought I’d ask…
The site is Linux hosting on a Zeus Web Server with Register365
Thanks,
Richie
Hi,
I thoroughly followed the instruction above but I’m still getting an error.
Is there anyone willing to help/figure out what seems to be the problem.
I’m in a week searching for the solution but I have to luck.
http://vvaengineering.com/ is hosted with TPP Console and usig Zeus server.
The current custom permalink is set to /index.php/%postname%/
If I removed the /index.php despite the rewrite.script i added to the server, I’m still getting error Page not found
Thanks in advance
Chris
Thanks Derek, just what I needed!
Thanks so much Derek, it worked like a magic.
Thanks Derek for the Article. Actually I didn’t face this problem yet with WordPress but when i read the title, I got curious to know is there anyone who get this kind of problem. And after reading the blog and comments, i am really surprised that many people have this kind of problems. So it’s good to read the tips as it can be helpful in future for me.
Please, help me. I have website on IIS (Windows Server 2012). I can’t find file .htaccess because i don’t use apache ect.
What I have to do?
thanks !
I’m also having the same problem. Aside from the homepage other page, category, or even if I have added a new post will go to 404 not found error. I don’t know what to do now..I’m not a fan of linux though.
Fixed my problem! Everything is working great now!
@Trendings Online: Great that you found the problem. What about sharing how you fixed it?
How did you get it fixed?
Thank you so much ! This was the best advice ever ! In my case the .htaccess file did not exist at all so after I created the file it worked like a charm !
a BIG thank you!
Perfect, it works! In my case (as per other people) there was no .htaccess at all, created it and now I got rid of that index.php. Thanks!
This article helps me a lot. Although I found this earlier before, I just remember about this when my friend asked me on how to fix the index.php problem. I also got a 404 page not found before and this helps me. Thanks Derek.
For those asking how to do this in IIS. First install URL Rewrite using Web Platform Installer. Then locate the root folder of where the WordPress website is installed eg. C:\inetpub\wwwroot\MyWordPressSite. Look for a web.config and if there isn’t one, create it. Paste the following which will create a rewrite rule. If the web.config file already exists then copy then system.webServer probably already exists. Paste the rewrite to /rewrite nodes into system.webServer:
Apologies, the above didn’t post the web.config contents. Hopefully the following works. Simply replace curly brackets with less than, greater than symbols:
{?xml version=”1.0″ encoding=”UTF-8″?}
{configuration}
{system.webServer}
{rewrite}
{rules}
{rule name=”WordPress: http://www.mywebsite.com” patternSyntax=”Wildcard”}
{match url=”*”/}
{conditions}
{add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true”/}
{add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true”/}
{/conditions}
{action type=”Rewrite” url=”index.php”/}
{/rule}{/rules}
{/rewrite}
{/system.webServer}
{/configuration}
Thanks found this useful at this time
Your explanation and steps are super clear. I was able to remove the /index.php/ reference from the site im working on. The server_name bit with the info.php file didn’t work though. just a blank screen. At first 404 error. Objective was achieved though. Just curious to know why the PHP part of your tutorial didn’t work.