开发者

How do I edit the .htaccess file to point to a relative directory for a 404 error document?

Most htaccess 404 error rules are based on an absolute directory location, eg /404.php. I want one that is relative to the location it's placed in (so when I transfer from test environment in WAMP to live, I don't have to hope I edit the file right).

Unfortunately,

ErrorDocument 404 404Error.php

Just prints out 404Error.php to the browser, it doesn't call the actual error page like

ErrorDocument 404 /FOOBAR/404Error.php

does.

Edit:

开发者_如何学编程

I guess I wasn't clear enough. Test environment is a WAMP local server, with the error file at /FOOBAR/404Error.php while the 'live' server would be www.fubar.com/404error.php -- placing it in the root.


How's this?

ErrorDocument 404 ../directory/404page.html


RewriteBase /FOOBAR/
ErrorDocument 404 404Error.php

This works too, but Tycho's solution is a bit more elegant. Only use this one if you don't plan on using .htaccess for anything outside of /FOOBAR/ pretty much.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜