我正在尝试在本地设置我的网络文件以进行测试。我的网站文件在我的文档文件夹中。我安装了xampp,并设置了apache来使用baseball.dev来打开我的本地网站。但是当我尝试使用它时,baseball.dev重定向到活动站点。我不知道为什么。
我的文件:
<VirtualHost *:80>
DocumentRoot "C:/Users/Kirst/Documents/GitHub/baseball-for-busy- people/"
ServerName baseball.dev
ServerAlias www.baseball.dev
<Directory "C:/Users/Kirst/Documents/GitHub/baseball-for-busy-people/">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>我的主机文件:
127.0.0.1 www.baseball.dev文件夹中有一个带有网站文件的htaccess文件。我认为这可能是造成问题的原因,但当我将它移除或评论时,它没有任何效果。这是那个文件:
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
# Apache Rewrite Rules
<IfModule mod_rewrite.c>
# For security reasons, Option followsymlinks cannot be overridden.
# Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
# Rewrite baseballforbusypeople.com as www.baseballforbusypeople.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.baseballforbusypeople.com$ [NC]
RewriteRule ^(.*)$ http://www.baseballforbusypeople.com/$1 [L,R=301]
# Add trailing slash to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ $1/ [R=301,L]
# Remove .php-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php
# Remove .html-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^\.]+)/$ $1.html
# End of Apache Rewrite Rules
</IfModule>发布于 2015-05-24 16:01:54
下面的行导致重定向:
RewriteCond %{HTTP_HOST} !^www.baseballforbusypeople.com$ [NC]
RewriteRule ^(.*)$ http://www.baseballforbusypeople.com/$1 [L,R=301]因此,对www.baseball.dev的请求将重定向到www.baseballforbusypeople.com。
在dev服务器上,对上面的行进行注释,并将它们保留在生产服务器上。
此外,如果您仍然在经历重定向,请确保清除您的浏览器缓存。
发布于 2015-05-24 15:45:07
最明显的第一选择是在windows上使用ipconfig /flushdns进行刷新。您是否确认主机名www.baseball.dev确实指向127.0.0.1
另外,我注意到htaccess文件包含以下指令:据我所知,RewriteCond %{HTTP_HOST} !^www.baseballforbusypeople.com$ [NC]将重写.htaccess所在的站点的任何请求到.htaccess站点,我猜该站点就是活动站点。
https://stackoverflow.com/questions/30425313
复制相似问题