简体   繁体   English

如何为Laravel自定义URL?

[英]How do I customize an URL for Laravel?

Im on windows 10, trying to customize an url to use Laravel. 我在Windows 10上尝试尝试自定义URL以使用Laravel。 I dont want to acess the url using public folder on it. 我不想使用公用文件夹访问URL。 Im using wamp and apache is running on port 8080. So I edit the file wamp\\bin\\apache\\apache2.4.23\\conf\\extra\\httpd-vhosts.conf like this: 我正在使用wamp和apache在端口8080上运行。因此,我像这样编辑文件wamp \\ bin \\ apache \\ apache2.4.23 \\ conf \\ extra \\ httpd-vhosts.conf:

<VirtualHost *:80>
    DocumentRoot c:/wamp/www/
    ServerName localhost
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot c:/wamp/www/laravel_test/blog/public
    ServerName laravel_test.dev    
</VirtualHost>

After that, I edit the file system32/drivers/etc/hosts with: 之后,我使用以下命令编辑文件system32 / drivers / etc / hosts:

127.0.0.1 localhost

127.0.0.1 laravel_test.dev

And when I access the url laravel_test.dev it doesnt work. 当我访问laravel_test.dev时,它不起作用。 I tried to use this too on httpd-vhosts.conf: 我也尝试在httpd-vhosts.conf上使用它:

<VirtualHost *:8080>

And it doesnt work either. 而且它也不起作用。 I always restart the service on wamp, and nothing changes. 我总是在wamp上重新启动服务,并且没有任何变化。

I couldnt install and configure the homestead properly, so im trying to use wamp now. 我无法正确安装和配置房屋,因此我现在尝试使用沼泽。 Can somebody help me? 有人可以帮我吗?

In your httpd.conf file you need to uncomment the virtual Hosts section 在您的httpd.conf文件中,您需要取消注释虚拟主机部分

Then, 然后,

Your vhost needs to listen on port 8080 您的虚拟主机需要在端口8080上侦听

<VirtualHost *:8080>
 ServerName laraveltest.dev
 ServerAlias www.laraveltest.dev 
 DocumentRoot c:/wamp/www/laravel_test/blog/public
   <Directory "c:/wamp/www/laravel_test/blog/public">
  AllowOverride All
 Options Indexes MultiViews FollowSymLinks
  Require all granted
</Directory>
</VirtualHost>

For your hosts file 对于您的主机文件

127.0.0.1 laraveltest.dev www.laraveltest.dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM