• Resolved sanuja

    (@sanujacom)


    I have the WordPress install on a separate folder called “blog” within the root www folder. The root folder has its own index.php file with a landing page.

    After I updated my WordPress .htaccess file to force the WP install to take HTTPS (TLS) over HTTP, all my error pages (such as Error 404) redirect to the WordPress error page. For example, any error in URL for https://sanuja.com/ will direct to 404 page associated with my WP blog install not the general 404 page.

    What am I missing here? Did I accidentally deleted some .htaccess code when when I forced the HTTPS?

    I do see the following in the root .htaccess (non-WordPress) section.
    ErrorDocument 401 /401.shtml
    ErrorDocument 403 /403.shtml
    ErrorDocument 404 /404.shtml
    ErrorDocument 500 /500.shtml

    I also noticed that all the pages in https://sanuja.com/blog/ now can be access without the “blog” part in the URL. The WP is not in the root and why is it that visitors can access a blog post without the “blog” in the URL?

    You can try visiting, https://sanuja.com/blog/about and also try without the “blog” part and it will still load the WordPress page instead of giving a general 404 error page.

    Thank you so much!

    • This topic was modified 5 years, 12 months ago by sanuja. Reason: spelling

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • The normal .ntaccess rules for WP say “if it’s not a file and it’s not a folder, give it to WP’s index.php file”. That is in the WP folder. If you copy that also to the root folder, you get what you are describing.
    WP can be in a folder and control just that folder (and subfolders). Or it can be in a folder and control the root, when you have a .htaccess file and a index.php that loads it from the folder.

    Thread Starter sanuja

    (@sanujacom)

    @joyously Thank you so much for the response. What code set should I be looking to delete from the root .htaccess folder that may be causing this URL redirect issue?

    I have a feeling that I must have done something to the .htaccess files for this issue to appear recently.

    • This reply was modified 5 years, 12 months ago by sanuja.

    You can read about .htaccess at https://ww.wp.xz.cn/support/article/htaccess/
    The last line is usually
    RewriteRule . /index.php [L]
    which depends on what is in the index.php for what happens next, but if my WP is in the wp folder, it would look like
    RewriteRule . /wp/index.php [L]
    so it will load WP in the wp folder. So you have to check both .htaccess and index.php.

    Thread Starter sanuja

    (@sanujacom)

    @joyously Thanks again.

    It is RewriteRule ^ https://sanuja.com%{REQUEST_URI} [NE,L,R] in the root directory .htaccess that is causing the problem. I commented it out for now because I cannot find a solution.

    Is there way I can still force HTTPS on the root without having this problem? WP install on the blog directory seems to doing fine with its own .htaccess with forced HTTPS.

    I tried the following but all of them cause /blog/ URL to be able to accessed without the “blog” part:

    RewriteRule ^https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteRule ^https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R]
    RewriteRule ^blog %{REQUEST_URI} [NE,L,R]
    

    I am looking into https://httpd.apache.org/docs/2.4/rewrite/flags.html but no luck.

    Thread Starter sanuja

    (@sanujacom)

    I found the issue after chatting with a developer on Facebook. Thank you Joy and everyone.

    For anyone reading this thread in the future, it was caused by an old Rewrite Rule I added in the root folder long time ago. I deleted the following:

    RewriteRule ^ /blog%{REQUEST_URI} [L]

    Then I added the following:

    
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Apache htaccess page URL issues’ is closed to new replies.