Solved

mod_rewrite handling custom error pages

Posted on 2006-11-11
6
383 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
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
In this blog, I will share you some basic tips for content marketing and to rank your website on Google.
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

810 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