我试图在本地设置我的Web文件进行测试。我在我的文档文件夹中有我的网站文件。我安装了xampp,并设置了Apache以使用baseball.dev来调出我的本地网站。但是当我尝试使用它时,baseball.dev会重定向到活动网站。我不知道为什么。本地站点重定向到生活站点
我的httpd的虚拟主机文件:
<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>
我的hosts文件:
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>
这工作。谢谢! – amylynn83