Help with htaccess and two Wordpress instances
I have an old legacy application, written in php. It's going to be replaced by two Wordpress instances, one being the website itself and the other being a blog (I have to use them separated as two instances). So I'm going to have a dir for this old version, a dir for the site and a dir for the blog.
This is my situation now:
Suppose my app url is http://www.mywebsiteurltest.com/
and my dir structure is as follows:
..htdocs/old_site/
files.php
files.css
blog/
wordpress files
I'm terrible at htaccess. So, since http://www.mywebsiteurltest.com/
is pointing to htdocs/old_site/
, writing http://www.mywebsiteurltest.com/blog/
goes to htdocs/old_site/blog/
. So my solution was to create a dir named blog instead of a .htaccess solution to redirect.
I want a more professional solution. I would like my dir structure to be:
..htdocs/
old_site/
site/
blog/
So, http://www.mywebsiteurltest.com/
would go to htdocs/site/
, and http://www.mywebsiteurltest.com/blog/
to htdocs/blog/
. I would like to know how to create an .htaccess
on htdocs/
to accomplish this. In the end I need to have 3开发者_开发问答 .htaccess:
htdocs/.htaccess
with this configuration (knowing to which dir it's going to go), manually made by me with your help
htdocs/site/.htaccess
again, but with site wordpress instance configuration, made automatically by wordpress
htdocs/blog/.htaccess
, but with blog wordpress instance configuration, made automatically by wordpress
So you want this, right?
http://www.example.com/ --> /htdocs/site/
http://www.example.com/blog/ --> /htdocs/blog/
http://www.example.com/old_site/ --> /htdocs/old_site/
If so, you can try this...
/htdocs/.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_URI} !^/old_site/
RewriteCond %{REQUEST_URI} !^/site/
RewriteRule ^.*$ /site/$0
/htdocs/site/.htaccess (What WordPress should do + a little extra):
RewriteEngine On
RewriteBase /
# Prevent people from going to /site/ directly
RewriteCond %{THE_REQUEST} ^[A-Z]+\s/site [NC]
RewriteRule ^.*$ http://www.example.com/$0 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
/htdocs/blog/.htaccess (What WordPress should do):
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
精彩评论