开发者

Codeigniter Routes for filename with extension

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.

I want to include a bunch of search engine related files (for Google webmaster etc.) plus the robots.txt file, all in a controller.

So, I have create the controll开发者_如何学运维er and updated the routes file and don't seem to be able to get it working with these files.

Here's a snip from my routes file:

$route['robots\.txt|LiveSearchSiteAuth\.xml'] = 'search_controller/files';

Within the function I use the URI helper to figure out which content to show.

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 :)


You should not need to escape the full stop, CodeIgniter does most of the escaping for you.

Here is a working example I use:

$route['news/rss/all.rss'] = "news/rss";


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)

Became

RewriteCond $1 !^(index\.php|content|favicon.ico)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜