【问题标题】:Working with multiple url segments codeigniter使用多个 url 段 codeigniter
【发布时间】:2019-07-29 16:08:21
【问题描述】:

我正在使用 url 段,到目前为止,提供 1 个 url 段运行良好。 “http://doupnow.com/morevideo/downloaded”这里的“downloaded”是参数,“morevideo”是方法。

但现在我正在尝试传递 3 个 url 段。在这种情况下,它显示“找不到页面错误”

为了达到同样的效果,我做了以下更改。

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

routes.php

$route['moreaudio/(:any)'] = 'home/moreaudio/$1';
$route['playaudio/(:any)/(:any)/(:any)'] = 'home/playaudio/$1/$2/$3';

第一条路线正在使用 1 个 url 段。

控制器方法

public function playaudio($aurl, $athumb, $atitle)
    {
        $result['aurl']=$aurl;
        $result['athumb']=$athumb;
        $result['atitle']=$atitle;
        $this->load->view('header');
        $this->load->view('audioplay', $result);
        $this->load->view('footer');

    }

调用url段的view.php

<?php echo "<a href='playaudio/$row3->audio_url/$row3->audio_thumb/$row3->audio_title' target='_blank'>"; ?>

请让我知道我哪里出错了。谢谢。

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    查看 ::

       <a href="<?php echo base_url('all/playaudio/audio_url/audio_thumb/audio_title');?>">Link</a>
    

    控制器:

     public function playaudio()
    {
    
        $result['aurl']   = $this->uri->segment('3');
        $result['athumb'] =  $this->uri->segment('4');
        $result['atitle'] =  $this->uri->segment('5');
    
        $this->load->view('header');
        $this->load->view('audioplay', $result);
        $this->load->view('footer');
    
    }
    

    .htaccess

     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ index.php/$1 [L]
    

    【讨论】:

    • 检查了这个但同样的问题,找不到页面。我是否必须在 .htaccess 文件中添加任何行
    • 请检查htaccess
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-17
    • 2012-09-25
    • 2014-05-11
    • 1970-01-01
    • 2015-11-23
    • 1970-01-01
    相关资源
    最近更新 更多