jeremib
jeremib

Reputation: 751

.htaccess redirect to cached file if exists

I have an index.php file in my root web dir. I want to check if /cache/index.html exists FIRST, and if so, display it.

Otherwise, continue using /index.php

Apache is configured to display index.html first, then index.php, so one thought I had was symlink /index.html to /cache/index.html, but I would rather not.

Thanks

Upvotes: 0

Views: 344

Answers (1)

nitro2k01
nitro2k01

Reputation: 7745

One way to do it is

DirectoryIndex cache/index.html index.php 

Note that this affects all subdirectories, as well, relative to the subdirectory. If you try to load htt://www.example.com/blub/ (and /blub/ exists) first /blub/cache/index.html is searched, then /blub/index.html. This generally isn't a problem, but you might want to add index.html or other index names used at the end of the directive.

Upvotes: 1

Related Questions