Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring WordPress .htaccess to view subfolders

I have a WordPress installation with an .htaccess file that looks like this:

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

I tried installing a fresh copy of WordPress into a subdirectory for a separate blog and am getting 404 errors within the root WordPress when I try to view it. I'm assuming this is because of the .htaccess file.

How do I change it so that I can view the subfolder?

like image 683
thesmallprint Avatar asked Oct 13 '08 01:10

thesmallprint


People also ask

Does htaccess work on subdirectories?

You can add a . htaccess file to any directory that requires lenient permissions settings (such as 760, 766, 775 or 777). You can prevent the execution of scripts inside the directory and all its sub-directories. Also, you can prevent any files other than those of a certain type to be written to it.

How do I move from root to subdirectory in WordPress?

Click "General" on the dashboard on the left side of the screen. Change the address to the new directory in the "WordPress address (URL)" box. For example, if you want to have WordPress run in the subdirectory "blog," type "http://yourdomain.com/blog." Keep the Site Address (URL) field the same. Click "Save Changes."


2 Answers

For future reference, you may want to try this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog2/index.php [L]
</IfModule>
# END WordPress
like image 199
Sterling Hamilton Avatar answered Oct 04 '22 02:10

Sterling Hamilton


Edit#2: ok i think i figured this out, but it's pretty messy.

modify your base wordpress install's .htaccess file to look like this:

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

now, load a new copy of wordpress into "blog2/", and copy your wp-config.php file over to it. edit the "/blog2/wp-config.php" file and change the $table_prefix to something different than your first blog. (this will install both wordpresses into the same database).

once you've done that, you should be able to go to:

http://yourdomain.com/blog2/

and finish up the installation without issue. the initial problem was that the new copy of wordpress kept trying to use the first copy's wp-config.php file. moving it over manually fixed that all up.

because i'm insane, i tested this with two fresh copies, wrote a few test articles, and was able to navigate around without issue, so it should work :)

like image 38
Owen Avatar answered Oct 04 '22 03:10

Owen