2010-08-06 96 views
0

我想要使用codeigniter URL路由來路由URL。 我想電子郵件重定向URL像codeigniter中的URL路由問題

  • /用戶/編輯?到UserController中/ editemail
  • /用戶/編輯?密碼UserController中/ editpassword

我使用下面的行嘗試routes.php在配置文件夾中

$route["users/edit?(email|password)"] = "userController/edit$1"; 

這顯示頁面未找到。我在猜測?正在被視爲正則表達字符。我試圖逃脫它,但也沒有工作。

我不想將配置設置uri_protocol設置爲PATH_INFO或QUERY_STRING,因爲這只是我想設置的一個漂亮的URL,不會將任何操作傳遞給操作。

有人能幫我一下嗎?

問候

回答

0

你應該逃避?這樣,它應該工作。 (未測試)

$route["users/edit\?(email|password)"] = "userController/edit$1"; 

後來編輯

這按預期工作:

$route["users/edit(email|password)?"] = "userController/edit$1"; 

userController看起來像這樣

<?php 

class UserController extends Controller { 

    function edit() 
    { 
     echo "general edit"; 
    } 

    function editemail() 
    { 
     echo "edit email!"; 
    } 

    function editpassword() 
    { 
     echo "edit password"; 
    } 
} 

路由器的工作原理是這樣的:

  • 如果你去http://sitename/index.php/users/editemail你看editemail()行動。
  • 如果你去http://sitename/index.php/users/editpassword你看到editpassword()的動作。
  • 如果你去http://sitename/index.php/users/edit看到edit()動作(問號使得可選的電子郵件/密碼字段,你可以在edit()行動
+0

@Bogdan做一些其他的事情 - 已經嘗試過了,失敗了奇蹟。如果這與允許的URL字符有關,它沒有任何地方,但它沒有顯示「URI已經禁止字符」消息,它顯示「頁面未找到」 – vikmalhotra 2010-08-06 08:02:55

+0

我做了一個測試,現在作品。稍後檢查編輯!:) – 2010-08-06 08:11:14

+0

@Bogdan - 我沒有得到。你在以後的編輯中寫的是不是應該用於諸如'users/editemail','users/editpassword'和'users/edit'這樣的URL呢? URL中的問號在哪裏?我在用戶/編輯密碼中遇到問題。 – vikmalhotra 2010-08-06 08:16:22