【发布时间】:2011-03-19 21:51:45
【问题描述】:
我在使用代码点火器路由时遇到了困难。
http://www.mysite.com 找到正确的控制器并做正确的事。但是,http://www.mysite.com/?ref=p&t2=455 会导致 404 错误。 http://www.mysite.com/mycontroller/mymethod/?ref=p&t2=455 也可以正常工作。
我更改了 config.php 文件中的 uri_protocol 并尝试了不同的值。自动似乎效果最好。
我的理论是代码点火器正在使用查询参数来进行路由。问题是这些查询参数与路由无关。
如何告诉代码点火器忽略默认控制器的查询参数?
注意,我按照在线说明从 URL 中删除了 index.php。我不认为它会导致问题,但这是我的 .htaccess 文件以防万一:
RewriteEngine On
RewriteBase /~trifecta/prod/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]
【问题讨论】:
-
从
RewriteRule行中删除问号,除非您使用的是疯狂的 CGI 主机或其他东西。
标签: codeigniter redirect get http-status-code-404