的.htaccess不会对虚拟主机的工作 [英] .htaccess doesn't work on VirtualHost

查看:151
本文介绍了的.htaccess不会对虚拟主机的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我设置一个<一个href="http://stackoverflow.com/questions/26575276/wildcard-domains-with-virtualhost-with-apache-on-mac">wildcard虚拟主机我的htaccess的文件不工作了。

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

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>

的.htaccess (字preSS默认)

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>

我可以访问的http://word$p$pss.dev ,也后端但像 HTTP不是一个网页://字press.dev /页(将导致404错误)。
我可以设置固定链接结构为默认,但我想有漂亮的网址

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"

我在Mac OS X上10.10本地开发环境与Apache 2.4

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

推荐答案

更​​改虚拟主机定义:

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

这篇关于的.htaccess不会对虚拟主机的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆