简体   繁体   English

带有Symfony应用程序的Wordpress博客-Apache Alias配置

[英]Wordpress blog with Symfony app - Apache Alias config

I have a Symfony app and I want run Wordpress on the subdirectory /blog. 我有一个Symfony应用,我想在子目录/ blog上运行Wordpress。 The Wordpress installation is on its own directory, not in the web folder of Symfony. Wordpress安装位于其自己的目录中,而不在Symfony的Web文件夹中。

The problem is that Wordpress doesn't execute the index.php file and when I go to myweb.com/blog i see the "Index Of" page with a list of all wordpress folder files. 问题是Wordpress不会执行index.php文件,当我转到myweb.com/blog时,我看到“ Index Of”页面,其中列出了所有wordpress文件夹文件。

This is my vhost config file: 这是我的vhost配置文件:

<IfModule mod_ssl.c>


<VirtualHost *:443>
ServerName      www.myweb.com

DocumentRoot    "/var/www/webs/myweb/web"
DirectoryIndex  app.php

<Directory "/var/www/webs/myweb/web">
    AllowOverride None
    Allow from All

    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_URI} !^/blog(/.+)? [NC]
        RewriteRule ^(.*)$ app.php [QSA,L]
    </IfModule>
</Directory>

  Alias "/blog/" "/var/www/webs/mywordpress"


  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^(.*) https://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

  RewriteCond %{HTTPS} off
  RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]


KeepAlive            On
MaxKeepAliveRequests 200
KeepAliveTimeout     5

<IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE "application/atom+xml" \
                                  "application/javascript" \
                                  "application/json" \
                                  "application/rss+xml" \
                                  "application/x-javascript" \
                                  "application/xhtml+xml" \
                                  "application/xml" \
                                  "image/svg+xml" \
                                  "text/css" \
                                  "text/html" \
                                  "text/javascript" \
                                  "text/plain" \
                                  "text/xml"
</IfModule>

<IfModule mod_headers.c>
    Header append Vary User-Agent env=!dont-vary

ExpiresActive On
ExpiresByType image/x-icon "now plus 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/js "access 1 week"
ExpiresByType application/javascript "access 1 week"
</IfModule>
SSLCertificateFile /etc/letsencrypt/live/www.myweb.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.myweb.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

The symfony app is in: var/www/webs/myweb symfony应用程序位于:var / www / webs / myweb

The Wordpress app is in: var/www/webs/mywordpress Wordpress应用位于:var / www / webs / mywordpress

And the wordpress htaccess is: wordpress htaccess是:

Options -Indexes
DirectoryIndex index.php

# BEGIN WordPress
<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>
# END WordPress

Any idea of what i'm doing wrong? 任何我在做什么错的想法吗? Thanks a lot. 非常感谢。

Make sure you have the necessary configuration for your wordpress as well. 确保您也为wordpress设置了必要的配置。

<Directory "/var/www/webs/mywordpress">
  AllowOverride All
  Allow from All
</Directory>

https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride Reading from here you can see that if you don't specify anything apache won't read anything from .htaccess file Using AllowOverride All tells apache to allow the htaccess to override the apache config If you want to make it more strict then use https://httpd.apache.org/docs/2.4/mod/core.html#allowoverride从这里阅读,您可以看到,如果您未指定任何内容,则apache不会从.htaccess文件中读取任何内容。允许htaccess覆盖apache配置如果要使其更严格,则使用

<Directory "/var/www/webs/mywordpress">
  AllowOverride FileInfo Indexes
  Allow from All
</Directory>

FileInfo to allow mod_rewrite directive and Indexes to allow DirectoryIndex FileInfo允许mod_rewrite指令,而Indexes允许DirectoryIndex

Thanks, it worked! 谢谢,成功了! After the Alias directive I added this config lines: 在Alias指令之后,我添加了以下配置行:

<Directory "/var/www/webs/mywordpress">
    DirectoryIndex  index.php
    Options +Indexes
    AllowOverride All
    Allow from All
</Directory>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM