开发者

.htaccess rewrite to root file of same name if no matching subdir

How would I write my htaccess to look for a file of the same name as a non-existent sub-directory? For instance, if I head to example.com/about and there is no 'about' sub-dir, I want to rewrite (not redirect) to the file example.com/about.html (and of course, keeping the 开发者_StackOverflow中文版URL as typed). In other words, is there a sub-dir of the requested name? If not, is there a file in the root of the same name? If yes, serve it up; if not, proceed to the usual 404.

Thanks in advance!


Have a look at the MultiViews option as specified here.

You should just have to set it like this:

<Directory /home/www/sitename/htdocs>
Options + MultiViews
</Directory>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜