Home How to do an internal redirect with CodeIgniter for robots.txt?
Reply: 0

How to do an internal redirect with CodeIgniter for robots.txt?

user1046
1#
user1046 Published in April 22, 2018, 12:54 am

I have a server running Apache 2.2.24 and CodeIgniter 2.1.0 .

I want to handle requests for /robots.txt dynamically, using CodeIgniter, but the only solution I have found so far is to use .htaccess to issue a temporary redirect that tells clients to fetch /robots_txt instead (note the underscore).

RewriteRule ^robots\.txt$ /robots_txt [NC,L,R=307]

Later in the .htaccess there are these rules for CodeIgniter:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1

Within CodeIgniter I can route requests for robots_txt to a controller.

My question is, how can I change this to an internal redirect? That is, when I get a request for robots.txt, instead of issuing a redirect response to the client, how can I rewrite the url to handle it internally as robots_txt?

Anything I have tried leads to a 404.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301564 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO