views:

46

answers:

1

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

+3  A: 

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]
Tim Stone
I've edited my question: "So, `http://www.mywebsiteurltest.com/` would go to `htdocs/site/`, and `http://www.mywebsiteurltest.com/blog/` to `htdocs/blog/`."
Somebody still uses you MS-DOS
Yeah, that's what this should do (although maybe you don't want to be able to access old_site at all, I wasn't sure about that). Does it not work, or?
Tim Stone
It works but when I try to access www.example.com/wp-login.php it nevers logs in - it always come back to www.example.com/wp-login.php. Im going to give up, it's hard to me to debug and try to understand all these lines, and in the future if I need to change/edit it I may not be able to do it. Thanks anyway.
Somebody still uses you MS-DOS