PDA

View Full Version : .htaccess ErrorDocument



Hypertext
03-10-2008, 09:50 PM
I'm using .htaccess for custom error pages and did this:


# Custom Errors
ErrorDocument 401 /sitemap?err=401
ErrorDocument 403 /sitemap?err=403
ErrorDocument 404 /sitemap?err=404
ErrorDocument 500 /sitemap?err=500

When I go to say example.com/somepagethatdoesntexist

it gives me a defaultl 404 with an additional 500 when the ErrorDocument failed...

I don't know why this is. :/

Edit: May aswell put in my other problem..
The whole .htaccess is:


Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^services services.php
RewriteRule ^about about.php
RewriteRule ^portfolio portfolio.php
RewriteRule ^portfolio/([A-Za-z0-9]+)/([0-9]+)/?$ portfolio.php?c=$1&id=$2 [L]
RewriteRule ^hosting hosting.php
RewriteRule ^quote quote.php
RewriteRule ^contact contact.php
RewriteRule ^blog blog.php
RewriteRule ^press press.php
RewriteRule ^affiliations affiliations.php
RewriteRule ^faqs faqs.php
RewriteRule ^sitemap(.*) sitemap.php$1
RewriteRule ^testimonials testimonials.php
# Custom Errors
ErrorDocument 401 /sitemap?err=401
ErrorDocument 403 /sitemap?err=403
ErrorDocument 404 /sitemap?err=404
ErrorDocument 500 /sitemap?err=500


Portfolio and the actual sitemap?err=500 don't work.. I get a 500 from them. /portfolio does but /portfolio/print/1 doesn't, with sitemap, /sitemap doesn't sitemap?err=x doesn't either.

RYANNNNN
04-10-2008, 12:18 AM
Check your error log, are you sure you have a file called "sitemap" with no extension, because otherwise I'm pretty sure it won't work.

Hypertext
04-10-2008, 01:37 AM
I have a file called sitemap.php, which is rerouted (look above) at

Line 15: RewriteRule ^sitemap(.*) sitemap.php$1
My theory was that sitemapanything would redirect to sitemap.phpanything as an example...

Blob
05-10-2008, 03:41 PM
I think what your trying to do is make it so its like what digg do, where its like digg.com/login?user=name&password=lol

ye?

If so,
RewriteRule ^sitemap sitemap.php

No need for the (.*) as htacccess just adds anything with ? onto the end of the php file.

Hypertext
05-10-2008, 06:21 PM
Thanks.

But I just decided to do /sitemap/404

I'm using RewriteRule sitemap/(.*)$ /sitemap.php?err=$1 [L]
but it isn't working.. it gets me to sitemap.php but doesn't append the $_GET var.

Edit, got it, it was my PHP. :rolleyes: Sorry.

Want to hide these adverts? Register an account for free!