codeigniter:如何仅删除URL中的索引方法

时间:2018-03-29 13:17:06

标签: php codeigniter codeigniter-3

我在一个类中使用多个方法。我只想从url中删除索引而其他方法保持不变;

www.mysite.com/blog/index
www.mysite.com/blog/index/one/two
www.mysite.com/blog/myblog
www.mysite.com/blog/data_load/one/two

4 个答案:

答案 0 :(得分:2)

希望这会对您有所帮助:

route.php

中的

$route['blog'] = 'blog/index';

确保:

配置文件中的

设置为:

 $config['base_url'] = 'http://localhost/foldername/';

 $config['index_page'] = '';

答案 1 :(得分:2)

在application / config / routes.php中尝试这个:

$route['blog/myblog']                   = 'blog/myblog';
$route['blog/data_load/(.+)/(.+)']      = 'blog/data_load/$1/$2';
$route['blog']                          = 'blog/index';
$route['blog/(.+)']                     = 'blog/index/$1';
$route['blog/(.+)/(.+)']                = 'blog/index/$1/$2';

注意:路由将按照定义的顺序运行。较高的路线始终优先于较低的路线。

答案 2 :(得分:0)

你需要为此设置路线。

在application / config / routes.php文件中设置路由

$ route ['project / user / id /(:any)'] ='project / user / index / id / $ 1';

答案 3 :(得分:0)

您还可以使用.htaccess文件来处理它。 创建.htaccess文件并将此代码粘贴到其中

Sub CopyStrings()
Dim i As Long, ws1 As Worksheet, ws2 As Worksheet, currRow As Long, lastRow As Long, rowsToPaste() As String, rowToPaste() As String, j As Long, k As Long
currRow = 1
Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
'here you determine how many rows there are in Sheet1 to copy and parse
lastRow = ws1.Cells(ws1.rows.Count, 1).End(xlUp).Row

For i = 1 To lastRow
    'split current string into rows
    rowsToPaste = Split(Cells(i, 1).Value, ";")
    For j = LBound(rowsToPaste) To UBound(rowsToPaste)
        'split current row and iterate through values and paste then in Sheet2
        rowToPaste = Split(rowsToPaste(j), ",")
        For k = LBound(rowToPaste) To UBound(rowToPaste)
            ws2.Cells(currRow, k + 1).Value = rowToPaste(k)
        Next
        currRow = currRow + 1
    Next
Next
End Sub