简体   繁体   中英

Wordpress showing directory listing with Apache mod_rewrite enabled

I have an issue where my Wordpress site is just showing the directory listing and not the application when I access crmpicco.localhost.

This is /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>

I didn't have mod_rewrite enabled, which I thought was the issue, but I now have that enabled and it shows under loaded_modules in phpinfo();

core 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

The .htaccess file that lives in the /var/www/crmpicco/wordpress directory looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I clearly have some mis-configuration somewhere, but I don't know where.

I got to the bottom of this by removing the Alias on / and having the /wordpress directory as the DocumentRoot .

The relevant lines are:

<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>

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.

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