重定向 WAMP 中子文件夹的根目录
Redirect root of subfolder in WAMP
我目前有一个 WAMP 服务器 运行 2 个子文件夹,其中一个包含一个 Laravel 项目和一个 public 文件夹。
我不想创建 .htaccess
文件以从 /laravel
重定向到 /laravel/public
。
相反,我想从 Apache 更改 vhost
文件中的重定向。我知道如何将 WAMP (www) 的根文件夹重定向到 Laravel 的 public 文件夹,但我想要的是:
每当我进入 WAMP 的根目录时,我仍然会像往常一样看到一个包含文件夹的列表。
当我转到 /laravel
目录时,它会自动重定向到 /laravel/public
。
这就是我目前在 httpd-vhosts.conf
文件中的方式。
但这似乎对我不起作用,当我切换这两个位置时,我会自动发送到 the public 文件夹,但无法查看 www 文件夹。
我已经尝试 google 它,但最终只知道如何将 www 根目录重定向到子文件夹。
所以我的问题是:如何将 sub.folder 的根目录重定向到 public 文件夹?
你已经命名了你的两个虚拟主机 localhost
这不是虚拟主机的重点。像这样更改 laravel 项目 VH
<VirualHost *:80>
ServerName laravel.test
ServerAlias www.laravel.test
. . . Leave other code as you had it
</VirtualHost>
现在转到您的 HOST 文件并像这样添加域名 laravel.test
编辑C:\Windows\System32\drivers\etc\hosts
应该是这样的
127.0.0.1 localhost
127.0.0.1 laravel.test
::1 localhost
::1 laravel.test
然后重新启动 dnscache
或重新启动。
>net stop dnscache
>net start dnscache
NOTE: You shoudl never make localhost
available to the internet so change this line back to what it was originally in the localhost
VH definition
Require local
Also unless you actually want to make the laravel project availaibe on the internet do the same for that VH or if you want to make it available on your internal network set the Require like this
Require ip 192.168.1
假设您的子网以 192.168.1
开头,您的可能不同!
我目前有一个 WAMP 服务器 运行 2 个子文件夹,其中一个包含一个 Laravel 项目和一个 public 文件夹。
我不想创建 .htaccess
文件以从 /laravel
重定向到 /laravel/public
。
相反,我想从 Apache 更改 vhost
文件中的重定向。我知道如何将 WAMP (www) 的根文件夹重定向到 Laravel 的 public 文件夹,但我想要的是:
每当我进入 WAMP 的根目录时,我仍然会像往常一样看到一个包含文件夹的列表。
当我转到
/laravel
目录时,它会自动重定向到/laravel/public
。
这就是我目前在 httpd-vhosts.conf
文件中的方式。
但这似乎对我不起作用,当我切换这两个位置时,我会自动发送到 the public 文件夹,但无法查看 www 文件夹。
我已经尝试 google 它,但最终只知道如何将 www 根目录重定向到子文件夹。
所以我的问题是:如何将 sub.folder 的根目录重定向到 public 文件夹?
你已经命名了你的两个虚拟主机 localhost
这不是虚拟主机的重点。像这样更改 laravel 项目 VH
<VirualHost *:80>
ServerName laravel.test
ServerAlias www.laravel.test
. . . Leave other code as you had it
</VirtualHost>
现在转到您的 HOST 文件并像这样添加域名 laravel.test
编辑C:\Windows\System32\drivers\etc\hosts
应该是这样的
127.0.0.1 localhost
127.0.0.1 laravel.test
::1 localhost
::1 laravel.test
然后重新启动 dnscache
或重新启动。
>net stop dnscache
>net start dnscache
NOTE: You shoudl never make
localhost
available to the internet so change this line back to what it was originally in thelocalhost
VH definition
Require local
Also unless you actually want to make the laravel project availaibe on the internet do the same for that VH or if you want to make it available on your internal network set the Require like this
Require ip 192.168.1
假设您的子网以 192.168.1
开头,您的可能不同!