我想重写一个CodeIgniter应用程序的URL,虽然它似乎没有工作。 我有以下的事情设置;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/页/ 1 /欢迎)。
我在做什么错?
我认为你需要有htaccess的从URL中删除index.php文件,它应该工作 – 2011-12-21 10:01:55
不完全是,它不只是去掉“的index.php”,但也方法的名称;视图。 – Roel 2011-12-21 10:04:06
你检查过Apache日志,找出Apache是改写这?此外,您可能需要$ 1的非贪婪版本的匹配,即'^ pages /(.*?)/(.*)$' – 2011-12-21 10:14:02