路由和超文本的奇怪行为 [英] Strange behavior with routing and hypertext

查看:57
本文介绍了路由和超文本的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习网络开发.目前,我的网站的根地址已扩展为www.mywebsite.com/project2/project2/public. 从一页到一条路线有一个超链接:

I am learning webdevelopment. For now the root address of my website is extended like www.mywebsite.com/project2/project2/public. There is a hypenrlink from one page to a route:

<a href="/movetocomplete/{{$object->id}}">{{$object->name}}</a>

如果href仍然如上,则出现404错误,表明

If the href is left as above, there is a 404 error saying that there is nothing at

www.mywebsite.com/movetocomplete/id#.

www.mywebsite.com/movetocomplete/id#.

但是,如果href是

project2/project2/public/movetocomplete/{{$ object-> id}},

project2/project2/public/movetocomplete/{{$object->id}},

出现404错误,表示

www.mywebsite.com/project2/project2/public/project2/project2/publicmovetocomplete/id#.

www.mywebsite.com/project2/project2/public/project2/project2/publicmovetocomplete/id#.

路线是

Route :: get('/movetocomplete/{object}','UserController @ movetocomplete');

Route::get('/movetocomplete/{object}', 'UserController@movetocomplete');

推荐答案

我认为此链接的路由不应以斜线开头.

I think your Route for this link should not begin with a slash.

此网址的正确路由

Route::get('movetocomplete/{object}', 'UserController@movetocomplete');

只有欢迎根页面需要一个斜杠,只需一个斜杠.

And only the welcome root page needs a slash, just one slash.

Route::get('/', 'WelcomeController@index');

这是Nginx位置块的最低配置:

This is the minimum configuration for Nginx location block:

location / {
    try_files $uri /index.php$is_args$args;
}

location ~ ^/index\.php(/|$) {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $document_root;

    internal;
}

location ~ \.php$ {
    return 404;
}

这篇关于路由和超文本的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆