How do I combine WordPress permalink code and .htaccess redirect?

I’m trying to combine the following code so that the WordPress permalinks work in the main directory, waringis.com (top code) and a second domain, burrowpress.com, is redirected to the subdirectory ‘waringis.com/burrowpress’ (bottom code) –

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

RewriteEngine On 
RewriteCond %{HTTP_HOST}  burrowpress.com$ [NC]
RewriteCond %{REQUEST_URI} !^/burrowpress/.*$
RewriteRule ^(.*)$  /burrowpress/$1

Right now permalinks are working in WordPress and the redirect works but images have to be direct links to waringis.com/burrowpress/images/ instead of burrowpress.com/images/ – Any help is much appreciated…

Related posts

Leave a Reply

2 comments

  1. You need to swap your code blocks around. The [L] flag on the WordPress rules are stopping execution of the file at that line in their code since your special path would “pass” the WordPress REWRITE_COND statements:

    RewriteEngine On 
    RewriteCond %{HTTP_HOST}  burrowpress.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/burrowpress/.*$
    RewriteRule ^(.*)$  /burrowpress/$1 [L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    

    You don’t need two RewriteEngine On statements, but since WordPress is able to rewrite your .htaccess file (depending on how you have it setup) you might want to leave it. If you are updating your file manually, you can remove the second RewriteEngine on directive.

    The important part is that I moved your special rules ahead of wordpress.

  2. I’m not a .htaccess expert but i would say that you don’t need to include RewriteEngine On twice that you can put the redirect code in the if statement. So you want to redirect to the subdomain but not have your images be kept in the subdomain is this correct?