xampp - mysite.local重定向到xampp文件夹

bso*_*d99 5 apache xampp localhost httpd.conf vhosts

我整个晚上一直在打击我的头,看不出我出错的地方.我想在xampp上设置一个主机mysite.local并遵循所有说明,但我一直被重定向到mysite.local/xampp.

我在这里出错的任何想法?路径是正确的,我重新启动了Apache :)

我编辑了我的hosts文件来添加:

127.0.0.1   mysite.local
Run Code Online (Sandbox Code Playgroud)

我编辑了extra/httpd-vhosts.conf:

NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
  Options Indexes FollowSymLinks MultiViews
   AllowOverride all
       Order Deny,Allow
       Allow from all
</Directory>
</VirtualHost>

<VirtualHost localhost:80>
<Directory "/Applications/XAMPP/xamppfiles/htdocs/wd">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride all
       Order Deny,Allow
       Allow from all
</Directory>
    DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/wd"
    ServerName mysite.local
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

Met*_*iel 4

我昨天刚刚遇到了同样的问题。即使您执行的步骤在上下文中是正确的,您还需要执行更多任务;)您还需要编辑httpd.conf引用新 VirtualHost 的 Apache,如下所示:

# Your great site!
<Directory "/Applications/XAMPP/xamppfiles/htdocs/wd">
  Options Indexes FollowSymLinks Includes ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)

仅凭这一点,您就可以http://mysite.local在不重定向到 XAMPP 初始屏幕的情况下进行访问,但是您将看到项目的目录(至少如果您没有根文件夹中的索引),如果您需要加载从文件夹(例如/public/index.php)中获取文件,您需要使用一个.htaccess文件。请记住,此文件必须位于您想要控制的文件夹中。例如,.htaccess要重定向到位于项目根目录的文件,/public/index.php您必须这样做:

RewriteEngine On
RewriteBase /
RewriteRule ^.*$ public/index.php [NC,L]
Run Code Online (Sandbox Code Playgroud)

请记住使用您需要的正确正则表达式,并且不要忘记在生产网站中采取更安全的预防措施;) 我希望我能帮助您 =)