views:

242

answers:

2

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

A: 

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";

Phil Sturgeon
Thanks for taking the time - your comment lead me towards the eventual answer (removing a rewrite condition allowing these files to be accessed directly).
thehuby
A: 

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