• Right so I’ve installed wordpress into a /content DIR off my root and built it up under there. Now when I wanted to go live I attempted to follow the ‘Using a pre-existing subdirectory install’ guide but it didn’t work.

    http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install

    The problem should be easy to fix but I rarely fiddle with .htaccess so let me explain. In the /content dir my .htaccess is:

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

    But the problem is that my ROOT .htaccess already uses Rewrite rules that conflict. Here’s a shortened example of my ROOT .htaccess:

    AddType x-mapp-php5 .php
    
    ErrorDocument 404 http://www.mysite.com/e404.shtml
    ErrorDocument 403 http://www.mysite.com/e403.shtml
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^(.*) http://www.mysite.com/$1 [L,R=301] 
    
    RewriteRule ^cgi-bin/polls/archive.html /cgi-bin/polls/_polls.cgi?archives=1 [L]

    WP’s guide suggests to MOVE my /content .htaccess into the root, so naturally for me I need to merge the two. At first I tried to put the following in my ROOT .htaccess (it was all pasted directly below “RewriteRule ^(.*) http://www.ispreview.co.uk/$1 [L,R=301] “):

    RewriteBase /content/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /content/index.php [L]

    I had to remove “RewriteBase /content/” as that caused too many problems with existing scripts and files. Now almost everything works but for two problems.

    1) I have a ton of redirects that now return 404 errors. Just one is shown in my example (” RewriteRule ^cgi-bin/polls/archive.html /cgi-bin/polls/_polls.cgi?archives=1 [L] “). This is no doubt related to the confusion caused by telling my site to look in /content, but how do I fix it? I tried adding “content/cgi-bin/polls… etc.” at the start (in both the root and /content .htaccess) but that didn’t work. What do I do?

    2) If somebody types http://www.mysite.com/index.shtml (this was my old static index file before I removed it for WP’s index.php) it, unlike before, no longer automatically redirects to index.php and just shows a 404 error. So I need calls to the index.html / index.shtml files to link into the correct index.php (i.e. http://www.mysite.com).

    Can anybody help?

    PS – I have several domains that link into my site so for various obvious SEO etc. reasons I can’t afford to lose these as they tell my other domains to become http://www.mysite.com. This is v.important:

    RewriteCond %{HTTP_HOST} !^www\.mysite\.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^(.*) http://www.mysite.com/$1 [L,R=301]

Viewing 1 replies (of 1 total)
  • Thread Starter ispreview

    (@ispreview)

    I finally got around MOST (but not all) of the problems by putting the WP .htaccess code (and changing it a little) BELOW all of my other rewrites in the ROOT as follows..

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

    This worked but some problems remain. For example, any attempt to ‘Preview’ a post I’m writting in WP fails with a 404 and I can’t rewrite or even redirect wordpress links. For example I want to redirect requests to my old RSS feed (/news/rss.xml) to WP’s feed at /feed but nothing I try (e.g. RewriteRule ^news/rss.xml /feed [QSA,L]) seems to work. It just brings up an odd error about being the wrong WP template?

    Also my old site was at index.shtml but now anybody going to index.shtml in the root doesn’t auto-redirect to the working index, it just returns 404. Once again any attempt to rewrite or redirect for a fix fails with a 404.

    Help.

Viewing 1 replies (of 1 total)
  • The topic ‘How to merge WP sub-dir htaccess with my ROOT htaccess’ is closed to new replies.