| 3:22 pm on Nov 1, 2012 (gmt 0)|
1. You need to exclude external requests for "/" from being rewritten so that the DirectoryIndex directive can then action the request. Mod_rewrite gets to it first and DirectoryIndex never gets a chance.
2. You need to exclude internal subrequests for index.htm from being rewritten. At present your ruleset only stops requests for index.php from being rewritten (this prevents an infinite loop). If requests (internal or external) for index.htm are rewritten, you'll never be able to access the index.htm file content.
You do not need the
RewriteBase /index.php - looks incorrect too.
| 3:54 pm on Nov 1, 2012 (gmt 0)|
Ok, the Wordpress stuff was already in there.
How do I exclude internal requests? And why does the RewriteBase /index.php look incorrect?
| 10:21 pm on Nov 1, 2012 (gmt 0)|
|RewriteBase /index.php - looks incorrect too. |
It is, but fortunately it has no effect. After very close poring over the documentation, it turns out that the RewriteBase is stuck onto the front of a Rewrite (capitalized) target when-and-only-when the target does not begin with protocol-plus-domain and does not have a leading slash. In other words, never ;)
| 3:12 pm on Nov 5, 2012 (gmt 0)|
I'm still no nearer an answer for the problem.
How do I exclude internal requests? I can't find much meaningful documentation online about them.
| 3:16 pm on Nov 5, 2012 (gmt 0)|
I think (but am not certain) that Wordpress redirects index.php to the root
| 3:34 pm on Nov 5, 2012 (gmt 0)|
But I need the Wordpress site to function as it is, but, both index.htm and index.php need to function separately, with the index.htm taking preference for the root URL.
| 3:35 pm on Nov 5, 2012 (gmt 0)|
Looking at THE_REQUEST with a RewriteCond checks that it is an external request.
| 5:31 pm on Nov 5, 2012 (gmt 0)|
|But I need the Wordpress site to function as it is, but, both index.htm and index.php need to function separately, with the index.htm taking preference for the root URL. |
Do you have a DirectoryIndex directive of your own? Generally on shared hosting you don't need one, because the server's config file has a generic version, and a normal directory won't have more than one index file. But here it is probably safer to have an explicit
DirectoryIndex index.htm index.php
Both versions work exactly the same. I think the one-line version is more intuitive. (And takes up fewer bytes ;))
|The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name.... Several URLs may be given, in which case the server will return the first one that it finds. |
Note carefully that Apache will stop at the first listed name that it finds; later names don't override earlier ones. So start with the form you want users to get if they simply request www.example.com.
If you want to look it up for yourself, note also that Apache's example shows it inside a <Directory> envelope. Do not use this envelope in htaccess. Ever. It isn't just unnecessary; it's an error.
| 3:02 pm on Nov 6, 2012 (gmt 0)|
The problem is actually wordpress - this call, in a PHP file placed within a plugin, will solve the problem:
| 4:22 pm on Nov 6, 2012 (gmt 0)|
Thanks for all the replies.
Figured out it was actually Wordpress causing the issue. The remove_filter line above works fine when placed into the functions.php file. Along with the DirectoryIndex rule in .htaccess, has produced the effect I was after.