Merge WordPress .htaccess with another script

I have a wordpress website and I want to place an application to a third level domain, but I stuck on nonfunctional .htaccess script.

First part of code is basic .htaccess configuration for WordPress like this.

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

Second part of script is this. Everything what is in folder subdom will be third level domain.

RewriteEngine On

# cele domeny (aliasy)
RewriteCond %{REQUEST_URI} !^domains/
RewriteCond %{REQUEST_URI} !^/domains/
RewriteCond %{HTTP_HOST} ^(www.)?(.*)$
RewriteCond %{DOCUMENT_ROOT}/domains/%2 -d
RewriteRule (.*) domains/%2/$1 [DPI]

# subdomeny (s nebo bez www na zacatku)
RewriteCond %{REQUEST_URI} !^subdom/
RewriteCond %{REQUEST_URI} !^/subdom/
RewriteCond %{HTTP_HOST} ^(www.)?(.*).([^.]*).([^.]*)$
RewriteCond %{DOCUMENT_ROOT}/subdom/%2 -d
RewriteRule (.*) subdom/%2/$1 [DPI]

# aliasy - spravne presmerovani pri chybejicim /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^domains/[^/]+/(.+[^/])$ /$1/ [R]

# subdomeny - spravne presmerovani pri chybejicim /
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^subdom/[^/]+/(.+[^/])$ /$1/ [R]

If both parts are alone they work perfectly, but if I merge it togeather the problem comes!

I have tried exclude folder with my application from the first part of script with this code, but it is not good. The application folder located in subdom folder is called masaze

RewriteCond %{REQUEST_URI} !(masaze) [NC]
RewriteRule ^masaze/.$ - [PT]

Can you please help me resolve this riddle?

Related posts

1 comment

  1. but if I merge it togeather the problem comes!

    Don’t merge the two scripts into the same .htaccess file. Create a second .htaccess in the /subdom folder for the “second part of the script”. (This is preferable since it keeps the separate application separate.)

    Providing you are only using mod_rewrite, which you appear to be, then the code in /subdom/.htaccess will completely override /.htaccess when accessed via your subdomain.

Comments are closed.