1

I apologize for the seemingly duplicate issue posting but I can't seem to find someone who has come across my specific issue and resolved it. This post got close but I did everything they did.

here's where I'm at:

  • migrated a wp site to an AWS server running ubuntu 18
  • rewrite mod is enabled
  • site is in /home/ubuntu/sites/my-wp-site
  • site dir is owned by www-data
  • site's virtual hosts file has the necessary "Directory" section with "AllowOverride All" set
  • site's .htaccess file has the rewrite rules set by the permalinks settings in the UI
  • apache2 config also has the "AllowOverride All" set for a "Directory" section pointed at /home/ubuntu/sites

What am I missing?

.htaccess

contents after setting the permalinks to date and time (empty otherwise)

 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_expires.c>
        ExpiresActive On
        ExpiresByType image/jpg "access plus 1 year"
        ExpiresByType image/jpeg "access plus 1 year"
        ExpiresByType image/gif "access plus 1 year"
        ExpiresByType image/png "access plus 1 year"
        ExpiresByType text/css "access plus 1 month"
        ExpiresByType application/pdf "access plus 1 month"
        ExpiresByType text/javascript "access plus 1 month"
        ExpiresByType text/html "access plus 5 minutes"
        ExpiresByType image/x-icon "access plus 1 year"
        ExpiresDefault "access plus 6 hours"
</IfModule>
<ifModule mod_headers.c>
Header set X-Endurance-Cache-Level "2"
</ifModule>
Options -Indexes

                                <IfModule mod_rewrite.c>
                                        RewriteEngine On
                                        RewriteBase /
                                        RewriteRule ^/wp-content/endurance-page-cache/ - [L]
                                        RewriteCond %{REQUEST_METHOD} !POST
                                        RewriteCond %{QUERY_STRING} !.*=.*
                                        RewriteCond %{HTTP_COOKIE} !(wordpress_test_cookie|comment_author|wp\-postpass|wordpress_logg$
                                        RewriteCond %{DOCUMENT_ROOT}/wp-content/endurance-page-cache/$1/_index.html -f
                                        RewriteRule ^(.*)$ /wp-content/endurance-page-cache/$1/_index.html [L]
                                </IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

apache2.conf

...
<Directory /home/ubuntu/sites/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>
...

vhost for site

...
DocumentRoot /home/ubuntu/sites/my-wp-site.com
...
<Directory /home/ubuntu/sites/my-wp-site.com>
     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted
</Directory>
...
  • What is the DocumentRoot? When you say the vHost has the necessary Directory section, can you confirm the file system path this is set for. Please include the contents of your .htaccess file and where exactly this is located. If you add some nonsense to your .htaccess file, does it “break”? – MrWhite Sep 21 at 10:06
  • The site is working fine so the vhost settings are accurate. The directory is pointed at the site (/home/ubunut/sites/mywpsite). I've updated the question with the .htaccess. – fischgeek Sep 21 at 12:13
  • "The site is working fine so the vhost settings are accurate." - but how can you be sure; permalinks aren't working? There is a syntax error on one of your _CondPattern_s here: |wordpress_logg$ - which implies either mod_rewrite is not enabled or .htaccess overrides are not enabled (otherwise you'd be getting a 500 response). – MrWhite Sep 21 at 13:03
  • @MrWhite - If the directory root is inaccurately entered in the vhost, then even the front page wouldn't render. Correct? mod_rewrite is enabled and confirmed by the console when I try to enable it. The typo in the .htaccess is a mystery considering I didn't put any of that in there manually. It was generated by selecting the radio button in the Permalinks settings. – fischgeek Sep 21 at 14:00
  • "If the directory root is inaccurately entered in the vhost, then even the front page wouldn't render. Correct?" - Not necessarily, there's insufficient info in the question. If your DocumentRoot is set to /home/ubuntu/sites, but are accessing your site as example.com/my-wp-site/ then the "front page" would render correctly but permalinks would not. However, the "syntax error" I mentioned above is a show-stopper and suggests your vHost/server config is indeed misconfigured (as stated). – MrWhite Sep 21 at 15:03
1

Since the domain/site has an ssl, the vhosts file for the ssl is separate and also needs to be updated. Not just the normal port 80 entry.

vhost (:80)

my-wp-site.com.conf

<VirtualHost *:80>
...
DocumentRoot /home/ubuntu/sites/my-wp-site.com
...
<Directory /home/ubuntu/sites/my-wp-site.com>
     Options Indexes FollowSymLinks
     AllowOverride All
     Require all granted
</Directory>
...
</VirtualHost>

vhost (:443)

my-wp-site.com-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ...
    ServerName my-wp-site.com
    ServerAlias my-wp-site.com
    DocumentRoot /home/ubuntu/sites/my-wp-site.com
    <Directory /home/ubuntu/sites/my-wp-site.com>
        Options None FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ...
</VirtualHost>
</IfModule>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.