I have been working on this for several hours. My goal was to redirect /index.php to /blog/wordpress/index.php. The conditions are  1. I have virtual hosting. 2. I don’t want to move the blog files to my root directory, nor do I want to point all web access to the subdirectory.

my root folder htaccess is:

DirectoryIndex /blog/wordpress/index.php

This works great at first, my root access is going to the blog folder. And when you navigate around the blog site, the sub directory shows correctly. ( I never wanted to hide that).

However, when I tried to access the admin panel (/blog/wordpress/wp-admin/) I get the posts page, instead the dashboard. If I type  eonsong.com/blog/wordpress/wp-admin/index.php, it works.

Then, I tried several 301 redirects I found online. They either have no effect or throw my into a re-direct loop.

————-

I then changed my permalinks on my blog site from eonsong.com/blog/index.php/2011/postname/ to eonsong.com/blog/2011/postname/  This didn’t work at first because I didn’t copy the last two lines. My final htaccess looks like this:


DirectoryIndex index.php

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

(I had to add DirectoryIndex index.php, otherwise, http://eonsong.com/blog/wordpress/ will give me 403.


After this, my blog pages are showing pretty links correctly. wp-admin/ still shows dashboard correctly.

I then changed my root .htaccess to use DirectoryIndex /blog/wordpress/index.php again. This time, everything seems to be working fine.


Mod_Rewrite Tutorial:

http://www.easymodrewrite.com/guide-syntax

root index.php redirects to subdirectory
Tagged on:             

Leave a Reply

Your email address will not be published. Required fields are marked *