Home » Wordpress » conflicting htaccess for subfolder wordpress

conflicting htaccess for subfolder wordpress

Posted by: admin November 30, 2017 Leave a comment

Questions:

I have a website www.domain.com with a subfolder www.domain.com/subsite/domain/ and in the subfolder there’s a wordpress installation.

currently the primary site works as it should and I’m able to view the wordpress index page and the admin area but every time I try to access one of the front-side inner pages I get a 404 error.

the primary htaccess file is:

RewriteEngine on
Options +FollowSymlinks

#RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider) [NC]
#RewriteRule ^wordpress/(.*)$  - [R=403,L]

RewriteCond %{REQUEST_URI} wordpress
RewriteRule (.*) $1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

rewritecond %{http_host} ^domain.com [nc]
RewriteRule ^(.*)$ http://www.domain.com [r=301,nc]

And the wordpress installation htaccess:

# WPhtc: End Custom htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

any help will be really appreciated

Answers:

Keep your primary htaccess file as this:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^subsite/domain(/|$) - [L,NC]

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

UPDATE:

And this should be your /subsite/domain/.htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subsite/domain/

RewriteRule ^index\.php$ - [L]

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