Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

mod_rewrite handling custom error pages

Posted on 2006-11-11
6
Medium Priority
?
392 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 2000 total points
ID: 17921306
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
ID: 17921317
>>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
ID: 17921323
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 49

Expert Comment

by:Roonaan
ID: 17921341
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
ID: 17921349
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
ID: 17921405
thank you

sean
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

963 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