簡體   English   中英

WordPress漂亮的永久鏈接故障轉移SSL-404文件不存在

[英]Wordpress pretty permalinks fail over SSL - 404 File does not exist

我無法使wordpress永久鏈接在Apache,Django 和SSL的Ubuntu服務器上運行。 如果禁用SSL,則配置工作正常,但啟用后失敗。 啟用S​​SL后,每個wordpress永久鏈接(不會映射到物理文件)都將產生404和apache錯誤日志中的條目,例如

File does not exist: /var/www/wpwrap/wordpress/hello-world

我嘗試了數十種stackoverflow和Web建議的解決方案(絕大多數用於非SSL設置)-沒有任何效果。 我對定義Apache配置(但不是wordpress)很熟悉,並且是這台機器的管理員。

1.我的apache設置

  • apache2.conf
    • 基本上開箱即用,不包含<Directory><VirtualHost>條目
    • 加載conf.d/*然后加載sites-enabled/*
  • httpd.conf(空)
  • 網站啟用/默認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.服務器設置

  • 預先存在的有效配置(運行一年)
    • Ubuntu 12.04
    • Apache 2.2.6(mpm_worker不是prefork)
    • Django(mod_wsgi)
      • Django在/提供服務的基本網址
    • mod_rewrite的
    • 443上的virtualhost(mod_rewrite將所有80個流量推送到443),SSL證書
  • WordPress的新功能
    • wordpress 4.2.1(與先前存在的Django並排運行)
      • WordPress在/ blog下提供網址
      • wordpress文件位於/ var / www / wpwrap / wordpress
    • mod_fastcgi和php-fpm
      • Server在worker mpm上表現良好,因此我安裝了有據可查的解決方案(php-fpm&mod_fastcgi)以使PHP與Apache worker mpm一起工作,而不是將Apache降級為僅用於wordpress的prefork mpm。

3.有效的方法:

  • 沒有SSL的永久鏈接(如果我只是將虛擬主機從443-> 80更改)
  • 通過SSL的Wordpress管理界面
  • 映射到實際存在的文件的任何wordpress網址
  • Django,SSL,現有重寫

4.其他事項除上述事項外,嘗試過:

對404沒有影響,並且出現以下任何錯誤:

  • 更改虛擬主機配置的順序(wordpress上方/下方的mod_wsgi)
  • 將整個虛擬主機設置移至已啟用站點/ default-ssl並重新加載
  • 使用wordpress文件的組(www-data)和權限(775)
  • 更改conf.d / *和啟用了sites // *的加載順序
  • 把我的頭撞在牆上:-)

解決了。

問題是與<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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM