问题描述
我使用codeigniter和它的路由系统成功与一些可爱的正则表达式,但我已经不舒服什么应该是一个容易peasy的东西在系统中。
I am using codeigniter and its routes system successfully with some lovely regexp, however I have come unstuck on what should be an easy peasy thing in the system.
想要在控制器中加入一堆与搜索引擎相关的文件(对于Google网站站长等)和robots.txt文件。
I want to include a bunch of search engine related files (for Google webmaster etc.) plus the robots.txt file, all in a controller.
因此,我创建了
这是我的路线文件的剪辑:
Here's a snip from my routes file:
$route['robots\.txt|LiveSearchSiteAuth\.xml'] = 'search_controller/files';
在函数中,我使用URI助手来确定要显示的内容。
Within the function I use the URI helper to figure out which content to show.
现在我不能得到这个匹配,这指向我的regexp是错误的。我确定这是一个非常明显的,但它的晚,我的咖啡因坦克是空的)
Now I can't get this to match, which points to my regexp being wrong. I'm sure this is a really obvious one but its late and my caffeine tank is empty :)
推荐答案
.htaccess文件,其中我创建了一个重写异常,允许直接访问搜索引擎文件,而不是通过codeigniter路由它们。
Issue was actually in .htaccess file where I had created a rewrite exception to allow the search engine files to be accessed directly rather than routing them through codeigniter.
RewriteCond $1 !^(index\.php|google421b29fc254592e0.html|LiveSearchSiteAuth.xml|content|robots\.txt|favicon.ico)
成为
RewriteCond $1 !^(index\.php|content|favicon.ico)
这篇关于Codeigniter带扩展名的文件名的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!