简体   繁体   English

Laravel路由在WAMP上不起作用

[英]Laravel routing is not working on WAMP

For few days i've been searching how to resolve this issue, but nothing helped. 几天来,我一直在寻找如何解决此问题的方法,但没有任何帮助。

I have laravel project c:/wamp/www/laravel/public and only the default route is working(anything i put in it it will work), but any other route is not. 我有laravel项目c:/ wamp / www / laravel / public,只有默认路由有效(我放入的任何路由都可以工作),但其他路由无效。

These two routes i have at the moment. 我目前有两条路线。 First one works, second one not. 第一个有效,第二个无效。

Route::get('/', function () {
    return view('page.home');
});

Route::get('/shows', function () {
    return view('page.shows');
});

I tried many things in .htaccess, httpd.conf, httpd-vhosts.conf that i found on the internet but nothing works. 我在.htaccess,httpd.conf,httpd-vhosts.conf中尝试了很多东西,这些东西我在互联网上都找到了,但是没有用。

I've enabled rewrite_module in httpd, i've tried adding virtual host to ti or httpd-vhosts: 我已在httpd中启用rewrite_module,我尝试将虚拟主机添加到ti或httpd-vhosts:

<VirtualHost *:80>
DocumentRoot "c:/wamp/www/laravel/public"
ServerName autoplay.dev
<Directory "c:/wamp/www/laravel/public">
        Options FollowSymLinks Indexes Multiviews
        AllowOverride All
        Order deny,allow
        Allow from 127.0.0.1
        Deny from all
        Require all granted 
</Directory>

This is my .htaccess file: 这是我的.htaccess文件:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    Options +FollowSymLinks
    RewriteEngine on

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

In it i tried RewriteBase as well but it didn't help. 在其中我也尝试了RewriteBase,但没有帮助。

Now when i try to go to any other page except home page(it's the same if i have a route or not) i get error NOT FOUND: The requested URL /wamp/www/laravel/public/index.php was not found on this server. 现在,当我尝试转到除主页以外的任何其他页面时(无论是否有路线,这都是相同的),我得到未找到的错误:找不到请求的URL /wamp/www/laravel/public/index.php该服务器。

Please don't ask if views are in page folder and similar questions, that is correct because it's working if i switch it in default route. 请不要问视图是否在页面文件夹中以及类似的问题,这是正确的,因为如果我将其切换为默认路径,它就可以正常工作。

Can you please help me because i've been searcing and trying for few days and this is bad for my health :D 您能帮我吗,因为我一直在努力寻找和尝试了几天,这对我的健康不利:D

Thanks :) 谢谢 :)

In your virtual host file, 在您的虚拟主机文件中,

<VirtualHost *:80>
DocumentRoot c:/wamp/www/laravel/public
ServerName autoplay.dev
</VirtualHost>

Use below code in your .htaccess file:- 在.htaccess文件中使用以下代码:-

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Now check autoplay.dev/ in your browser. 现在,在浏览器中检查autoplay.dev/

Link :- https://laravel.com/docs/5.0/installation#pretty-urls 链接-https : //laravel.com/docs/5.0/installation#pretty-urls

Check this link also. 还要检查此链接

Hope it will help you :) 希望它能对您有所帮助:)

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

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