启用Apache mod_rewrite的Wordpress显示目录列表

时间:2019-03-07 04:06:22

标签: php wordpress apache mod-rewrite vhosts

我遇到一个问题,当我访问crmpicco.localhost时,我的Wordpress网站仅显示目录列表,而不显示应用程序。

这是/usr/local/etc/httpd/extra/httpd-ssl.conf

##
## SSL Virtual Host Context
##

<VirtualHost _default_:443>

#   General setup for the virtual host
DocumentRoot "/var/www/crmpicco/"
ServerName crmpicco.localhost:443
ServerAlias www.crmpicco.localhost
ServerAdmin crmpicco@crmpicco.com
ErrorLog "/private/var/log/apache2/error_log"
TransferLog "/private/var/log/apache2/access_log"
DirectoryIndex index.php

<Directory "/var/www/crmpicco">
    AllowOverride All
</Directory>

<Directory "/var/www/crmpicco/wordpress">
    AllowOverride All
</Directory>

Alias /app /var/www/crmpicco/symfony/web
Alias / /var/www/crmpicco/wordpress

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on
</VirtualHost>

我没有启用mod_rewrite,我认为这是问题所在,但是我现在启用了该功能,它显示在loaded_modules的{​​{1}}下

  

核心mod_so http_core prefork mod_authn_file mod_authn_core   mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_core   mod_access_compat mod_auth_basic mod_socache_shmcb mod_reqtimeout   mod_filter mod_mime mod_log_config mod_env mod_headers mod_setenvif   mod_version mod_ssl mod_unixd mod_status mod_autoindex mod_vhost_alias   mod_dir mod_alias mod_rewrite mod_php7

位于phpinfo();目录中的.htaccess文件看起来像这样:

/var/www/crmpicco/wordpress

我显然在某处配置有误,但是我不知道在哪里。

1 个答案:

答案 0 :(得分:0)

通过删除Alias上的/,并将/wordpress目录作为DocumentRoot,使问题根深蒂固。

相关行是:

<VirtualHost _default_:443>

DocumentRoot "/var/www/crmpicco/wordpress"
ServerName crmpicco.localhost:443
ServerAlias www.crmpicco.localhost
ServerAdmin crmpicco@crmpicco.com
ErrorLog "/private/var/log/apache2/error_log"
TransferLog "/private/var/log/apache2/access_log"

<Directory "/var/www/crmpicco/wordpress/">
        Options +FollowSymLinks
        DirectoryIndex index.php
        Options -Indexes
        Require all granted
        AllowOverride all
</Directory>

Alias /app /var/www/crmpicco/symfony/web

...

</VirtualHost>