Laravel 5.2:Windows IIS服务器中仅路由'/'有效 [英] Laravel 5.2 : only route '/' works in windows iis server
问题描述
今天,当我尝试在Windows iis服务器中访问我的项目路由时遇到了问题.
today I had a problem when I try to access my project route in windows iis server.
我的应用程序网址为:demo.example.com/testing/
my application url is : demo.example.com/testing/
根路由有效'/'
,但彼此之间不起作用.
the root routing is working '/'
, but not with the other.
例如,如果我尝试使用'/home/'
路径单击菜单,则该URL将类似于demo.example.com/home'
,而'testing'
则消失了.
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:我已经删除了'public'
文件夹,将公共文件夹中的所有文件都移到了外面,并将其他文件移到了新文件夹中.
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::get('/', 'frontend\frontController@index');
Route::get('/login', 'frontend\frontController@login');
感谢您的帮助!
推荐答案
归结为URL重写.我遇到了完全相同的问题,我需要在web.config中添加一条规则:
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>
此博客文章: https://laracasts.com/discuss/channels/servers/iis- 8-laravel-webconfig
这篇关于Laravel 5.2:Windows IIS服务器中仅路由'/'有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!