Solved

mod_rewrite handling custom error pages

Posted on 2006-11-11
6
380 Views
Last Modified: 2008-03-17
ive got my .htaccess file:

RewriteEngine on
RewriteRule ^$ index.php [nc]
RewriteRule ^(.*)\.htm$ $1.php [nc]
RewriteRule ^(.*)\.html$ $1.php [nc]
RewriteRule ^about(/)?$ about.php [nc]
RewriteRule ^portfolio(/)?$ portfolio.php [nc]
RewriteRule ^portfolio(/)([0-9/]+)(/)?$ portfolio.php?pid=$1 [nc]
RewriteRule ^contact(/)?$ contact.php [nc]
RewriteRule ^sitemap(/)?$ sitemap.php [nc]
ErrorDocument 400 /400.htm
ErrorDocument 401 /401.htm
ErrorDocument 402 /402.htm
ErrorDocument 403 /403.htm
ErrorDocument 404 /404.htm
ErrorDocument 500 /500.htm
ErrorDocument 502 /502.htm

ive got my custom error pages in folder called errors like:

W:/apache/site/htdocs/errors

main pages exist under:

W:/apache/site/htdocs

if an error occurs like a page not found etc i what my URL to look like:

http://www.site.com/error/400/  <---- obviously this will show the 400.htm contents
http://www.site.com/error/401/
http://www.site.com/error/402/
http://www.site.com/error/403/
http://www.site.com/error/404/
http://www.site.com/error/500/
http://www.site.com/error/502/

but it int working.

any suggestions?

ellandrd
0
Comment
Question by:ellandrd
  • 4
  • 2
6 Comments
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
Comment Utility
Then you should build 404.htm to php-header('Location:") redirect to /error/400/

I don't see the benefit of this however, because you loose reference to the actual file/url on which the error occurred.

-r-
0
 
LVL 16

Author Comment

by:ellandrd
Comment Utility
>>I don't see the benefit of this however, because you loose reference to the actual file/url on which the error occurred

ok what would you suggest doing in my case to show tidy URL of error pages?
0
 
LVL 16

Author Comment

by:ellandrd
Comment Utility
and when i mean it isnt working, when i create an error to test it, i dont get send to error pages at at. i just get page not found.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 49

Expert Comment

by:Roonaan
Comment Utility
The error page doesn't do a redirect. It just loads /404.html as the content for the current url.

Have you made sure you have 404.html in your correct directory?

Then, if you want the correct url's build 404.html to redirect to /error/404/, if you realy need this tidy urls.

-r-
0
 
LVL 16

Author Comment

by:ellandrd
Comment Utility
i have in my directory the following:

w:/apache/site/htdocs/index.php
w:/apache/site/htdocs/about.php
...
w:/apache/site/htdocs/400.htm
w:/apache/site/htdocs/401.htm
...

all im wanting for now is to get the error pages shown if an error occures.
0
 
LVL 16

Author Comment

by:ellandrd
Comment Utility
thank you

sean
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now