• Resolved duindain

    (@duindain)


    I have installed wordpress in a subfolder years ago for an existing site

    Checking on various support topics for this they seem to indicate that you should copy the index.php and .htaccess files into the root of your website then that will bounce it back up to the subdirectory based on the config, however that would overwrite the sites existing index page and different htaccess file so its not a viable solution

    When i try setting any permalink setting other than plain i get 404 errors, when its set to Plain it works correctly
    Plain produces a blank .htaccess file

    Setting to post-name produces


    # BEGIN WordPress
    # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /articles/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /articles/index.php [L]
    </IfModule>

    # END WordPress

    I’ve checked back and the htaccess file looks correct based on this tutorial
    https://www.wpbeginner.com/wp-tutorials/how-to-install-wordpress-in-a-subdirectory-step-by-step/comment-page-2/#comments

    I’ve tried temporarily commenting out the RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] section as that was the only difference but it did not help

    Is there some config i need to change in apache to help this work?

    Some sections from Site info

    Version	6.8.1
    Home URL https://rmu.no-ip.com/articles
    Site URL https://rmu.no-ip.com/articles
    Permalink structure No permalink structure set

    Plugins
    Akismet Anti-spam: Spam Protection Version 5.4 by Automattic - Anti-spam Team | Auto-updates enabled
    Enlighter - Customizable Syntax Highlighter Version 4.6.1 by Andi Dittrich | Auto-updates enabled
    ImageMagick Engine Version 1.7.13 by Orangelab | Auto-updates enabled
    Independent Analytics Version 2.11.9 by Independent Analytics | Auto-updates enabled
    UpdraftPlus - Backup/Restore Version 1.25.6 by TeamUpdraft, DavidAnderson | Auto-updates enabled

    Server
    Server architecture Linux 6.8.0-63-generic x86_64
    Web server Apache/2.4.58 (Ubuntu)
    PHP version 8.3.6 (Supports 64bit values)
    PHP SAPI apache2handler
    Is the Imagick library available? Yes
    Are pretty permalinks supported? Yes
    .htaccess rules Your .htaccess file contains only core WordPress features.
    robots.txt Your site is using the dynamic robots.txt file which is generated by WordPress.

    I currently have it set to Plain to keep the site working

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Checking on various support topics for this they seem to indicate that you should copy the index.php and .htaccess files into the root of your website then that will bounce it back up to the subdirectory based on the config, however that would overwrite the sites existing index page and different htaccess file so its not a viable solution

    Running a WordPress site from a subdirectory should not need any special treatment (except in some situations when you have another WordPress site in the root, which isn’t your case here).

    You may be confusing a tutorial on giving WordPress its own directory (where the WordPress files are placed in a subdirectory, say, /wordpress/, while the website runs from the root URL /). Since your “Home URL” and “Site URL” point to the same location, you don’t need to move any files around at all.

    Your broken permalinks may point to something fundamental: is your server equipped to handle the rewrites at all?

    Even though your server config in your post lists Apache, your site’s header shows you’re running the OpenResty server. If I’m not mistaken, this is Nginx-based, and Nginx cannot process .htaccess rules (that’s an Apache thing).

    So, check your Docker environment.

    Unless you’re proxying to Apache, then you need to add Nginx-specific rewrite rules (WordPress does not generate Nginx rewrite rules, but Google has a bunch). And if you have Apache (front or behind Nginx/OpenResty), then ensure it’s actually loaded in your running config, and that you have the mod_rewrite module loaded to handle the .htaccess rules.

    Thread Starter duindain

    (@duindain)

    Hey @gappiah, thanks for helping

    I am running apache, its on a VM not in docker, it is behind a nginx proxy

    I’ve managed to get this working now though I had mod_rewrite enabled I needed to set the default directory in the apache config to AllowOverride All otherwise regardless of what the actual virtualhost config was it was ignoring all .htaccess files, when i tried setting this in the virtualhosts it threw exceptions but in the main config file it seems fine

    The answer from FrankPl below was the key https://stackoverflow.com/questions/9153262/tips-for-debugging-htaccess-rewrite-rules

    I worked out that the .htaccess wasn’t working by enabling apache logging for it and adding a simple redirect from a random url on my site to a shortened one

    From the apache doco
    https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging
    Then watching the logs with tail -f error_log|fgrep '[rewrite:'

    When there was no output i was sure there had to be something misconfigured and then stumbled on the stack overflow post after 3-4 tries

    Thanks for your help everything works again for awhile 😉

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Permalinks from subdirectory return 404 unless using Plain’ is closed to new replies.