WordPress Permalinks not found in subfolder

6.5k Views Asked by At

I have WordPress installed in the root folder and in a subfolder. I can access the home page for the WordPress site in the subdomain, but the permalinks does not work – error 404. I have tried to reset the permalinks, but it did not help. I can’t find any .htaccess file, so I have created one myself and placed it in the subfolder directory:

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

Here is a link to the subfolder WordPress site: http://ninahortendesigns.com/projects/bigsargefitness/

I have set the database options to the above direction.

Thanks for your help.

2

There are 2 best solutions below

7
On BEST ANSWER

You will need to look at a few things:

  1. .htaccess file in the root WP site (WP1) and edit it so that WP1 doesn't catch the URLs and generate 404 errors, I'm not sure if that comment assisted, I've used this answer for a similar issue.
  2. .htaccess file in the sub WP site (WP2) and rename it to "htaccess.old" then log into your wp2/wp-admin, go to "Settings->Permalinks" check the URL structure is as desired (it doesn't usually change) and click "Save" at the bottom of the page. This will regenerate your .htaccess file within the context of the sub-directory and you shouldn't get 404 errors when you visit sub-pages like this

Here's the code from the first link edited so that it should work with your site, although if you have additional rules, you should only insert the line under the comment.

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI}  !(projects) [NC]

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

If you have custom rules, only insert these lines

# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI}  !(projects) [NC]

Assuming you're a designer and are uploading examples of sites you've built, you should only have to do step 2 the next time you upload a new site to the wp1/projects/ sub-directory

0
On

Cause

Error 404 occurs when the resource or path you requested cannot be reached. In this case it's likely because URL rewrite isn't working properly, hence the permalink requests were still being directed to the requested path (e.g. /projects/bigsargefitness/your-category/your-post-name) instead of the rewritten path (i.e. /projects/bigsargefitness/index.php).

The following solution assumes you use Debian/Ubuntu, otherwise the principles should remain the same.

Solution

  1. Firstly, ensure that the rewrite engine has been installed:

    sudo a2enmod rewrite
    
  2. Then, ensure that the engine is allowed for the subdirectory by editing/adding the following lines in the file /etc/apache2/sites-available/your-site.conf:

    <Directory /var/www/projects/bigsargefitness/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
    

    The key here is to ensure that the line says AllowOverride All instead of AllowOverride None.

  3. Finally, restart your server:

    sudo service apache2 restart
    

Let me know if this helps.