WordPress in subdirectory htaccess

Warning: This article was published many years ago (greater than two) Sep 27, 2014. Some information may be outdated.

wordpress in subdirectory htaccess

If the WordPress is installed in /wordpress subfolder then the blog can be accessed www.example.com/wordpress but if you want the blog to be default page servered by the web-server.. there are many ways to do this.. but involves modification to many files and coping index.php, wp-config.php etc.

A simple solution is to edit “.htaccess” in the root folder (if it does not exist use text editor to  create the file ) note the ‘.’ in file name

RewriteEngine On
# Not a necessity .. but a learn on .htaccess so that
# even Intranet access is available from Root..# OR is use
RewriteCond %{HTTP_HOST} ^(www.)?192.168.1.40$ [OR]
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteRule ^(/)?$ wordpress [L]
# Use the below if you want the user Browser to remember this redirect
# RewriteRule ^(/)?$ wordpress [L,R=301]

Edit 27 Sep 2014: “Pretty permalinks not working for sub-directory WordPress” with the above .htaccess

Solution: we require two .htaccess files

1. in the root .htaccess

RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^(www.)?tskamath.dyndns.biz$ [OR]
# the [OR] and the Next Line is not required, if the site is accessed using
# on one URL ie tskamath.dyndns.biz
RewriteCond %{HTTP_HOST} ^(www.)?tskamath.dscloud.biz$ [NC]
RewriteRule ^(/)?$ wordpress [L]
# Use the below if you want the user Browser to remember this redirect
# RewriteRule ^(/)?$ wordpress [L,R=301]

2. in the subdirectory where the wordpress is installed, in my case “wordpress”: Note the virtual host is not enabled

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

if the Virtual Host is enabled then the .htaccess file has to as follows (the root .htaccess file is not required when virtual host is enabled)

# BEGIN WordPress
<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

Pls note: with virtual host enabled, the wp-admin may not work: the issues will be in the general setting of the WordPress

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.