• Hello. I am having an issue with my staging site front end pages showing a 404 error. The backend pages and home page work fine but sub pages dont work so assume its htaccess related.

    Lets say I have mydomain.com.au and then I’ve made a copy as mydomain.com.au/staging/. When you view mydomain.com.au/staging/ and admin pages it works. But if you view mydomain.com.au/staging/shop it shows the live site with a 404 (as /staging/shop does not exist on the live site).

    If I view /staging/contact it auto changes to just /contact (the live contact page). It seems the htaccess on the root live site is overriding the htaccess in the staging folder.

    How do I get wordpress to respect a htaccess in a staging folder?

Viewing 2 replies - 1 through 2 (of 2 total)
  • AddWeb Solution

    (@addweb-solution-pvt-ltd)

    The default .htaccess file on root does not take into account that the WordPress sub-site is installed in a sub-folder as its site root path.
    As a result, WordPress is unable to interpret URL requests that are receiving the sub-directory level. since the requests are handled by .htaccess on the main root directory. As a result, the 404 pages not found errors are returned as obviously, the main WordPress installation does not know about the pages or posts in another instance of WordPress.

    To fix the issue, just modify the .htaccess for the WordPress site in the subdirectory to include the subfolder name.
    For example:

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

    (@katmacau)

    Thanks. I thought that was the case. I tried that but it resulted in an internal server error. Are there rules I can put into the root directory htaccess to tell it ‘about’ the staging directory rules? Eg can I put that line in the root htacess along with the main rewrite rule? Almost like an if else statement for how to rewrite?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Staging site front end pages showing 404’ is closed to new replies.