开发者

htaccess rewrite scenario

I have a scenario where I have two files, one is index.php and the other is index.htm.

How would I setup a rewrite condition / rule so that if index.htm exists on the server in a subdirectory, pass the request to this file. And if the file does not exist pass the r开发者_如何学JAVAequest to /index.php?


It depends on your subdirectory structure, but one solution would be to simply use index.php exclusively, and write some PHP at the front of index.php to check for the existence of the other file:

 if(file_exists("subfolder/index.htm")) exit(file_get_contents("subfolder/index.htm"));

Otherwise, check out the flags for RewriteCond

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html


No need for rewriting, use DirectoryIndex with an absolute path:

DirectoryIndex index.htm /index.php
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜