Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi there @petew1959.

    The issue you are facing is due to the rewrite rules in .htaccess file that resides in the subdirectory.

    Let’s say the name of your subdirectory is named ‘wp’.

    Edit the .htaccess file in that subdirectory and alter the rewrite rules as it follows:

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

    Please give it a try and see if the subpages are working as expected.

    Thread Starter PeteW1959

    (@petew1959)

    Thanks chemicloud, but my .htaccess is already like that.

    Ok I see what you are trying to achieve.

    Edit the .htaccess file in public_html directory and add the following lines of code to it:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.mydomain.com$
    RewriteCond %{REQUEST_URI} !wordpress/
    RewriteRule (.*) /wordpress/$1 [L]

    In this way the site will load the WordPress instance from wordpress subdirectory.

    Then go to wordpress subdirectory and modify the .htaccess file to:

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

    This should do the trick, and sub-pages should be reachable at https://www.mydomain.com/sub-page

    Finally, make sure that your site URL’s are set to use ‘https://www.mydomain.com&#8217;

    This guide may help – https://codex.www.ads-software.com/Changing_The_Site_URL

    Thread Starter PeteW1959

    (@petew1959)

    Thanks @chemicloud, that did the trick!

    You are quite welcome @petew1959!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WordPress in own directory’ is closed to new replies.