Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

mod_rewrite handling custom error pages

Posted on 2006-11-11
6
Medium Priority
?
388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Suggested Courses

722 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