簡體   English   中英

CodeIgniter URL重寫

[英]CodeIgniter URL rewriting

我試圖重寫CodeIgniter應用程序的URL,雖然它似乎不起作用。 我有以下幾件事;

$route['pages/(:num)/(:any)'] = "pages/view/$1/$2";
$config['index_page'] = '';

然后我有以下.htaccess;

RewriteEngine on
RewriteBase /

RewriteRule ^pages/(.*)/(.*)$ /index.php/pages/view/$1/$2 [L]

它只是說找不到頁面(Apache錯誤,而不是CodeIgniter)。 當我瀏覽到原始鏈接(http://domain.tld/index.php/pages/view/1/welcome)但在瀏覽到“所需”鏈接時(http://domain.tld/pages),它無效/ 1 /歡迎)。

我究竟做錯了什么?

難道你錯過了? 在你的RewriteRule中?

# Substitute " >>?<< " with "?". It's there to point you to the change.
RewriteRule ^pages/(.*)/(.*)$ /index.php >>?<< /pages/view/$1/$2 [L]

嘗試:

$route["pages/(.*)/(.*)"] = "pages/view/$1/$2";
//and your htacess, remove your current rule and
RewriteRule ^(.*)$ index.php/$1 [L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM