I am unable to get wordpress pretty permalinks to work on an Ubuntu server with Apache, Django and SSL . The configuration works fine if I disable SSL, but fails with it enabled. With SSL enabled, every wordpress permalink (that doesn't map to a physical file) results in a 404 and an entry in apache's error log like
File does not exist: /var/www/wpwrap/wordpress/hello-world
I have tried dozens of stackoverflow & web suggested solutions (vast majority for non-SSL setups) - nothing has worked. I am seasoned with defining Apache configs (but not wordpress) and am admin of this machine.
1. My apache setup
<Directory>
or <VirtualHost>
entries conf.d/*
then sites-enabled/*
sites-enabled/default-000
Out-of-the-box contents prior to this. (My separate 443 vhost listed below redirects all http traffic to https, so this file should be moot). For troubleshooting this issue, I changed EVERY <Directory>
entry in this file to explicitly contain these 2 lines. No effect.
Options FollowSymLinks AllowOverride All
conf.d/my-ssl-site.conf - My CORE configuration
<Location /> # preexisting, works fine <IfModule mod_rewrite.c> RewriteEngine on # force www prefix for plain example.com; RewriteCond %{HTTP_HOST} ^example\\.com RewriteRule ^(.*)$ https://www.example.com%{REQUEST_URI} [R=permanent,L] # force ssl RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=permanent] </IfModule> </Location> <VirtualHost *:443> ServerName example.com ServerAlias www.example.com ServerAdmin admin@example.com DirectoryIndex index.html ErrorLog "|/usr/sbin/rotatelogs -f -l /var/log/django/error.log.%Y.%m.%d 25M" CustomLog "|/usr/sbin/rotatelogs -f -l /var/log/django/access.log.%Y.%m.%d 25M" combined #FOR REWRITE DEBUGGING #RewriteLogLevel 10 #RewriteLog /var/log/django/rewrites.log # ======= RUN DJANGO/PYTHON THROUGH WSGI MODULE OF APACHE ============== # pre-existing, works fine WSGIScriptAlias / /path_to_my/wsgi.py WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP} WSGIProcessGroup example.com SSLEngine on # additional SSL config stuff snipped from here # ==== WORDPRESS Settings Alias /blog /var/www/wpwrap/wordpress <IfModule mod_fastcgi.c> AddHandler php5-fcgi .php Action php5-fcgi /php5-fcgi Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization </IfModule> <Directory /var/www/wpwrap/wordpress> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all DirectoryIndex index.php #pretty permalink setup, as defined by wordpress Admin UI <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteRule ^index\\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> </Directory> #Added these directories during wordpress troubleshooting - no effect <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> <Directory /usr/lib/cgi-bin/php5-fcgi> Options FollowSymLinks AllowOverride All </Directory> </VirtualHost>
There are no other <Directory>
configs or <VirtualHost>
configs or AllowOverride
lines in sites enabled, conf.d, or even in mods-enabled, anywhere within /etc/apache2.
2. Server setup
3. What works:
4. Other things Tried besides items noted above:
No effect on the 404 and error with any of the following:
Solved it.
The problem was a conflict with the <Location>
block, which contained another set of Rewrite Rules. Though the rules should not have collided (regex wise), somehow the Location rules were blocking execution of the Directory rules so they never ran at all.
Based on Apache docs which state that Rewrites are not officially supported in <Location>
blocks, I migrated all <Location>
rewrites into <VirtualHost>
entries for ports 80 & 443 in my conf.d/my-ssl-site.conf file. Now everything works.
I had all the same symptoms and found it was the SSL block in virtual hosts /etc/apache2/sites-available/mysite.com.conf
<VirtualHost _default_:443>
was missing a directory block...
<Directory /var/www/html/mysite.com/public_html/>
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
As soon as I had that all permalinks off the home page started working :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.