Solved

mod_rewrite handling custom error pages

Posted on 2006-11-11
6
386 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 500 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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 our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
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.
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).

734 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