Apache 如何为本地环境中的多个虚拟主机配置httpd-vhosts.conf?

Apache 如何为本地环境中的多个虚拟主机配置httpd-vhosts.conf?,apache,localhost,development-environment,Apache,Localhost,Development Environment,按照中的说明在本地计算机(运行MAMP的Windows)上使用不同的端口设置两个虚拟主机 出于某种原因,重写日志显示了辅助主机被剥离的所有内容,从而重定向到主主机。我遗漏了一些东西-可能.htaccess中遗漏了一些东西 提前感谢您提供的任何见解 主持人: 127.0.0.1 example.d1 ::1 example.d1 127.0.0.1 example.d2 ::1 example.d2 httpd-vhosts.con

按照中的说明在本地计算机(运行MAMP的Windows)上使用不同的端口设置两个虚拟主机

出于某种原因,重写日志显示了辅助主机被剥离的所有内容,从而重定向到主主机。我遗漏了一些东西-可能.htaccess中遗漏了一些东西

提前感谢您提供的任何见解

主持人:

127.0.0.1     example.d1
::1             example.d1
127.0.0.1     example.d2
::1             example.d2
httpd-vhosts.conf:

NameVirtualHost *:80
NameVirtualHost *:82

# ======= WordPress site 1 =======
 <VirtualHost *:80> 
    DocumentRoot "C:/MAMP/htdocs/example1-80"
    ServerName example.d1
    ServerAlias example.d1
    # these 4 lines enable error logs
    RewriteLogLevel 3
    RewriteLog "C:/MAMP/logs/rewrite.log"
    ErrorLog "C:/MAMP/logs/site1-error_log" 
    CustomLog "C:/MAMP/logs/site1-access_log" common 
 </VirtualHost>
 
# ======= WordPress site 2 =======
 <VirtualHost *:82> 
    DocumentRoot "C:/MAMP/htdocs/example2-82"
    ServerName example.d2
    ServerAlias example.d2
    # these 4 lines enable error logs   
    RewriteLogLevel 3
    RewriteLog "C:/MAMP/logs/rewrite.log"
    ErrorLog "C:/MAMP/logs/site2-error_log" 
    CustomLog "C:/MAMP/logs/site2-access_log" common 
 </VirtualHost>
NameVirtualHost*:80
名称虚拟主机*:82
#=======WordPress网站1=======
DocumentRoot“C:/MAMP/htdocs/example1-80”
ServerName示例1.d1
ServerAlias示例1.d1
#这4行启用错误日志
重写日志级别3
重写日志“C:/MAMP/logs/rewrite.log”
ErrorLog“C:/MAMP/logs/site1-error\u log”
自定义日志“C:/MAMP/logs/site1-access\u log”通用
#=======WordPress网站2=======
DocumentRoot“C:/MAMP/htdocs/example2-82”
ServerName示例.d2
ServerAlias示例.d2
#这4行启用错误日志
重写日志级别3
重写日志“C:/MAMP/logs/rewrite.log”
ErrorLog“C:/MAMP/logs/site2-error\u log”
自定义日志“C:/MAMP/logs/site2-access\u log”通用
httpd.conf:

DocumentRoot "C:/MAMP/htdocs"

<Directory />
    Options FollowSymLinks ExecCGI
    AllowOverride none
    Order deny,allow
    Allow from all
</Directory>

<Directory "C:/MAMP/htdocs">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

...

Alias /MAMP "C:/MAMP/bin/MAMP/"

<Directory "C:/MAMP/bin/MAMP/">
    Options Indexes MultiViews ExecCGI
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from localhost
    Allow from 127.0.0.1
</Directory>
DocumentRoot“C:/MAMP/htdocs”
选项如下symlinks ExecCGI
不允许超限
命令拒绝,允许
通融
选项索引跟随SYMLINKS ExecCGI
允许超越所有
命令允许,拒绝
通融
...
别名/MAMP“C:/MAMP/bin/MAMP/”
选项索引多视图执行CGI
不允许超限
命令拒绝,允许
全盘否定
允许从本地主机
允许从127.0.0.1开始
.htaccess在两个虚拟主机目录中都相同:

# Wordpress max file upload size
php_value upload_max_filesize 64M
php_value post_max_size 72M

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
#Wordpress最大文件上传大小
php\u值上传\u最大\u文件大小64M
php_值post_最大尺寸72M
#开始WordPress
#“开始WordPress”和“结束WordPress”之间的指令(行)为
#动态生成,只能通过WordPress过滤器修改。
#这些标记之间对指令的任何更改都将被覆盖。
重新启动发动机
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
#结束WordPress