• Resolved dfj1974

    (@dfj1974)


    Hi,
    Setting permalinks to ‘Post name’ is causing several 404 errors. Here’s the context:
    -The ‘News’ section of my website (abugovkaspar.com) is a nested WP page with multiple blog posts (WP 4.5.3 running ‘National Basic’ theme).
    -404 errors occur upon opening blog posts; front ‘News’ page seems to be unaffected.
    -Header and footer content is copied into WP Editor from the HTML for the main website for uniformity of appearance; 404 errors are affecting this header and footer content. Image files are not found; javascript, css, etc. is not found.
    -There are two .htaccess files; one in the root directory (/public) and another in the News directory. After researching this problem, I have tried adding the following to the .htaccess in the News directory (we are on an Apache server):

    <IfModule mod_rewrite.c>
    ReWriteEngine On
    ReWriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    This hasn’t helped. The following is an example 404 error:

    https://abugovkaspar.com/news/images/portfolio/architecture/royop/royop-subheader-01.jpg?lbisphpreq=1 Failed to load resource: the server responded with a status of 404 (Not Found)

    When I revert to ‘Plain’ permalink settings, the problem disappears. I am fairly new to WP, and am not much of a code guy; I appreciate any help that I can get with this.
    Dan

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi, Dan (@dfj1974). What’s tripping things up is the two periods included in all the relative URLs being used on the site; for example, here’s the one for the image you cited:

    <img src="../images/portfolio/architecture/royop/royop-subheader-01.jpg" alt="Royop Block" />

    The two periods mean “look two directory levels up”; so when you’re viewing a post with a URL like this one:

    https://abugovkaspar.com/news/gilchrist-manor-official-opening/

    then the image URL becomes relative to the second directory up, which is news:

    https://abugovkaspar.com/news/images/portfolio/architecture/royop/royop-subheader-01.jpg

    But the images folder is actually in the root directory, so the correct URL needs to be this one:

    https://abugovkaspar.com/images/portfolio/architecture/royop/royop-subheader-01.jpg

    which would happen automatically if you simply eliminated the two periods (keeping only the forward slash) in the HTML itself.

    (And the reason it works when you use plain permalinks is that they don’t include directory names at all, and a relative URL can only “move up” as far as the root directory itself.)

    Thread Starter dfj1974

    (@dfj1974)

    Perfect! Thank you for your help: you are an unstoppable Titan of WP advice. Issue hereby resolved.
    D

    Where did you see this? Where do I look if this is what’s happening to my site? Thanks

    Why does /index.php/%postname%/ work?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Permalinks set to 'Post name' returning 404 errors on WP page nested in website’ is closed to new replies.