For a long time I have wanted to modify the permalink structure but every time I deviated from the custom format below I end up receiving a rather nasty 404 error page.Granted I wrote the nasty 404 error page so it’s message does not bother me especially. It is more the fact that WordPress just was not playing nice with my installation.
/index.php/%year%/%monthnum%/%day%/%postname%/
After many years of playing around and tweaking things I finally stumbled upon the answer. The remaining issue was to fix my permalinks such that I could abandon the year/month/day format in addition to the whole index.php file. In other words I really wanted my timeless content to shine without loosing any of the link juice that 6 plus years of blogging can yield.
So the first issue was to modify the rewrite rules in my .htaccess to expedite the 301 redirection of the old post structure to the new streamlined domain name/post name structure. The following is an excerpt of the .htaccess rule I used to accomplish this.
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RedirectMatch 301 ^/index.php/({4})/({2})/({2})/([^/]+)/$ https://www.jafdip.net/$4 RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
At this point I still had not fixed the 404 error page rendering onĀ redirection. I discovered that because I run a self hosted instance of WordPress on Mac OS X Server and by default the http.conf has the AllowOverride directive set to None. Some sites I found during my search several individuals claimed to have fixed it by simple changing AllowOverride to All and chmoding the permission on .htaccess to 777 which is really kind of STUPID.
Honestly I can not think of any reason you would want to chmod anything in your web tree to be writable by the entire world let alone why you’d want to do this to such a critical system file for your website. On top of that setting your AllowingOverride directive to all is akin to turning off the security provided by your web server. It is really a bad practice and I just can not recommend you do it with out really understanding what you are doing.
<Directory "/Path/To/Your/Site"> AllowOverride FileInfo </Directory
In this case I set my AllowOverride to FileInfo which is still more secure than allowing everything. Once I did this I have to restart Apache in order to reload the config file. One thing to keep in mind is that rather than change that setting on all site across the system I am only changing it in the appropriate vhost configuration file.
I hope that this post helps someone some day avoid the frustration of trying to put the remove index.php & rewriterules of .htaccess together. I realize that if you are not hosting your site on Mac OS X Server you will not likely encounter this phenomenon unless your site’s administrator is very strict about hardening your WordPress installation. I would be very keen to know if you encounter this on other operating systems especially if it’s a stock installation.
Heyliger says
Nice web page you possess here.
Mikel King says
It would be a shame if something happened to it…
Sorry my mind falls into dark places easily….
Thanks
Tanja Talbert says
Hello There. I found your blog using msn. This is a very well
written article. I’ll make sure to bookmark it and return to read
more of your useful info. Thanks for the post. I will certainly
return.
anxiety depression stress treatment says
Howdy, i read your blog occasionally and i own a similar one and i
was just wondering if you get a lot of spam comments? If so how do
you stop it, any plugin orr anything you can advise? I get so much
lately it’s driving me crazy soo any help is very much appreciated.
Mikel King says
Akismet is a good plugin…