1

On my CodeIgniter site, I would like to add a specific rewrite rule, so that this url http://www.exemple.com/cache.manifest

would rewrite to

http://www.exemple.com/controller/manifest

(because Safari 7 seems to only accept .manifest files for ApplicationCache)

So I try to add this line to my htaccess

RewriteRule ^cache.manifest$ controller/manifest

I added it before the other rewrite rules :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^cache.manifest$ controller/manifest
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

But it returns a 404. If I change the line to

RewriteRule ^cache.manifest$ test.html

it works. So the first part on my rule is correct.

If I try to access directly to www.example.com/controller/manifest, it works to, so my url is correct.

I tried also

RewriteRule ^cache.manifest$ index.php/controller/manifest [L]

But it doesn't work either…

Any clue ?

Thanks a lot

Marc Audet
  • 46,011
  • 11
  • 63
  • 83
Matthieu
  • 563
  • 1
  • 7
  • 25
  • Have your tried: RewriteRule ^cache.manifest$ /index.php/controller/manifest [L] - you may need the / before index.php – Marc Audet Sep 30 '14 at 13:59
  • Just to be sure, cache.manifest is a file? – Marc Audet Sep 30 '14 at 14:23
  • no, cache.manifest does not exists. But it's the point of a RewriteRule, or I don't understand your question ? – Matthieu Sep 30 '14 at 14:24
  • Following [this link](http://stackoverflow.com/questions/12278652/htaccess-multiple-rewrite-rules-for-codeigniter?rq=1) in the "Related" section on the right, I discovered the ability to specify rewrite in the config/routes.php file, and it works ! `$route["cache.manifest"] = "controller/manifest";` It doesn't explain why the rewriterule in the htaccess doesn't work, but it's enough for me (although the safari 7 bug remains) – Matthieu Sep 30 '14 at 14:58
  • CodeIgniter's route module is quite useful and powerful. I posted a Apache solution below that may work, it would be good to know so please try it. Thanks for the update. – Marc Audet Sep 30 '14 at 15:22

1 Answers1

0

I tried some tests on my local server and I think the following might work:

RewriteRule ^cache.manifest$ /index.php/controller/manifest [R,L]

I am not entirely sure if you need the leading "/" or "/index.php", so you may need to experiment.

You need the [R] flag to force a redirect. In this situation, you want Apache to look for the string cache.manifest in the URL, and then go to the CI page controller/manifest.

It appears that you need to explicitly set the redirect.

Please let me know if this works. Good luck!

Marc Audet
  • 46,011
  • 11
  • 63
  • 83
  • Actually, I can't add the R tag, because I need the url to remains with a .manifest suffix – Matthieu Sep 30 '14 at 15:24
  • I see, this is a tricky one! In that case, the CI route module is the way to go. – Marc Audet Sep 30 '14 at 15:26
  • Anyway, thanks a lot for your help, Marc ! By the way, it didn't solve my problem, as the Safari bug wasn't related to the manifest name, but to the applicationCache.abort() function… :+/ – Matthieu Oct 01 '14 at 13:57