Laravel 5.2 : only route '/' works in windows iis server

南楼画角 提交于 2019-12-12 17:24:14

问题


today I had a problem when I try to access my project route in windows iis server.

my application url is : demo.example.com/testing/

the root routing is working '/', but not with the other.

for example, if I try to clicking menu with '/home/' route, the url will be like demo.example.com/home' , the 'testing' is gone somehow.

PS : I already remove the 'public' folder with moving all of files in public folder outside, and moving the other files into new folder.

Route example:

Route::get('/', 'frontend\frontController@index');

Route::get('/login', 'frontend\frontController@login');

Thanks for helping !


回答1:


it comes down to URL rewrites. I had the exact same issue, and I needed to add a rule in web.config:

<rule name="routes" stopProcessing="true">
                  <match url="^(.*)$" ignoreCase="false" />
                  <conditions logicalGrouping="MatchAll">
                      <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />                     
                  </conditions>
                  <action type="Rewrite" url="public/index.php/{R:1}" />

                </rule>

from this blog post: https://laracasts.com/discuss/channels/servers/iis-8-laravel-webconfig




回答2:


You are not supossed to place laravel in a subfolder. Your subdomain should directly point to the application without any further subfolders since Laravel will use absolute paths to navigate to your routes. e.g.

Route::get('home', ...)

will always navigate to yourdomain.com/home even though it actually maches yourdomain.com/laravel/home unless you make a lot of changes to your setup.




回答3:


Can you access the login page by demo.example.com/testing/public/index.php?/login

If yes, the problem probably in your server configuration or .htaccess

I've just encountered the same problem, for me enabling mod_rewrite for apache2 fix it.

You should probably read:

https://laravel.com/docs/5.0/configuration#pretty-urls

Can't route properly in Laravel

Can't access URL in Laravel routes

The last thing, You shouldn't do this thing below.

PS : I already remove the 'public' folder with moving all of files in public folder outside, and moving the other files into new folder.

Stop messing with the folder structure. Do not do things you don't know!



来源:https://stackoverflow.com/questions/38349759/laravel-5-2-only-route-works-in-windows-iis-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!