[英]Wordpress pretty permalinks fail over SSL - 404 File does not exist
我無法使wordpress永久鏈接在Apache,Django 和SSL的Ubuntu服務器上運行。 如果禁用SSL,則配置工作正常,但啟用后失敗。 啟用SSL后,每個wordpress永久鏈接(不會映射到物理文件)都將產生404和apache錯誤日志中的條目,例如
File does not exist: /var/www/wpwrap/wordpress/hello-world
我嘗試了數十種stackoverflow和Web建議的解決方案(絕大多數用於非SSL設置)-沒有任何效果。 我對定義Apache配置(但不是wordpress)很熟悉,並且是這台機器的管理員。
1.我的apache設置
<Directory>
或<VirtualHost>
條目 conf.d/*
然后加載sites-enabled/*
網站啟用/默認000
開箱即用的內容在此之前。 (下面列出的我單獨的443 vhost將所有http流量重定向到https,因此該文件應無意義)。 為解決此問題,我將該文件中的每個<Directory>
條目更改為顯式包含這兩行。 沒有效果。
Options FollowSymLinks AllowOverride All
conf.d / my-ssl-site.conf-我的核心配置
<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>
在/ etc / apache2中啟用,conf.d甚至啟用了mods的站點中,沒有其他<Directory>
配置或<VirtualHost>
配置或AllowOverride
行。
2.服務器設置
3.有效的方法:
4.其他事項除上述事項外,嘗試過:
對404沒有影響,並且出現以下任何錯誤:
解決了。
問題是與<Location>
塊發生沖突,該塊包含另一組重寫規則。 盡管規則不應該發生沖突(正則表達式明智),但是位置規則以某種方式阻止了Directory規則的執行,因此它們根本不會運行。
基於Apache文檔,該文檔指出<Location>
塊中不正式支持重寫,因此我將所有<Location>
重寫都遷移到conf.d / my-ssl-site.conf文件中端口80和443的<VirtualHost>
條目中。 現在一切正常。
我有相同的症狀,發現它是虛擬主機/etc/apache2/sites-available/mysite.com.conf
的SSL塊<VirtualHost _default_:443>
缺少目錄塊...
<Directory /var/www/html/mysite.com/public_html/>
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
一旦我知道主頁上的所有永久鏈接都開始起作用:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.