.htaccess doesn't work on VirtualHost

2019-09-06 06:34发布

Since I've setup a wildcard VirtualHost my htaccess files does not work anymore

The http-vhosts.conf

NameVirtualHost *

<VirtualHost *:80>
    ServerName default.dev
    VirtualDocumentRoot /Users/[UserName]/Sites/%-2
    <Directory /Users/[UserName]/Sites/%-2>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

the .htaccess (WordPress default)

<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 can access http://wordpress.dev and also the backend but not a page like http://wordpress.dev/page (causes a 404 error).
I can set the permalink structure to default but I would like to have "nice URLs"

I'm on a local development environment on Mac OS X 10.10 with Apache 2.4

1条回答
来,给爷笑一个
2楼-- · 2019-09-06 07:26

Change your VirtualHost definition to:

<VirtualHost *:80>
    ServerName default.dev
    VirtualDocumentRoot /Users/[UserName]/Sites/%-2
    <Directory /Users/[UserName]/Sites>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

i.e, root the directory definition to Sites, not to the virtual directory.

查看更多
登录 后发表回答