dongza6247 2016-10-09 02:03
浏览 7

路由和超文本的奇怪行为

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>

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

www.mywebsite.com/movetocomplete/id#.

But if the href is

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

there is a 404 error saying there is nothing at

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

The route is

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

  • 写回答

1条回答 默认 最新

  • douhang8991 2016-10-09 02:13
    关注

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

    The correct route for this url

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

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

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

    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;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测