我终于能够复制我的 Magento 商店,现在我能够在 git 中/使用 git 进行开发。
副本存储在/var/www.dev
所以我以为我复制了我的apache/站点可用/商店到同一文件夹中的 dev.shop,将配置从服务器名称 shop.com 至 dev.shop.com这就足够了。
不幸的是,我对 dev.shop.com 的所有请求都被重定向到 shop.com,我不知道为什么。
日志显示这是302 重定向。因此它不能是 Javascript,而且由于它在 php 程序运行之前,所以它必须是 apache 服务器。
这里有一些配置。
/etc/apache2/sites-available/shop.com
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.shop.com
ServerAlias shop.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName www.shop.com
ServerAlias shop.com
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/shop.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/shop.com.key
SSLCACertificateFile /etc/apache2/ssl/SSL_CA_Bundle.pem
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error_ssl.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access_ssl.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
这就是/etc/apache2/sites-available/dev.shop.com
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName dev.shop.com
ServerAlias dev.shop.com dev shop.com
DocumentRoot /var/www.dev
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www.dev/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName www.dev.shop.com
ServerAlias dev.shop.com
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/shop.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/shop.com.key
SSLCACertificateFile /etc/apache2/ssl/SSL_CA_Bundle.pem
DocumentRoot /var/www.dev
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www.dev/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error_ssl.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access_ssl.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
答案1
由于你的开发配置文件
/etc/apache2/sites-available/dev.shop.com
有
AllowOverride All
在目录的设置中
/var/www.dev/
您可能还会检查您的网站是否在 .htaccess 中使用了重定向
查找此文件是否存在
/var/www.dev/.htaccess
其中包含带有某些版本的重定向的条目。它可能会将访问开发主机的浏览器发送到生产主机。当您只是复制 Web 根目录中的所有文件,或使用某些版本控制系统将代码部署到两个地方而没有意识到 .htaccess 文件包含这些重定向时,就会发生这种情况。
如果是这样,您只需要调整重定向规则以重定向到开发站点。