ellandrd
asked on
mod_rewrite handling custom error pages
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/erro rs
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
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/]+)(/)?
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/erro
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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-
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-
ASKER
i have in my directory the following:
w:/apache/site/htdocs/inde x.php
w:/apache/site/htdocs/abou t.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.
w:/apache/site/htdocs/inde
w:/apache/site/htdocs/abou
...
w:/apache/site/htdocs/400.
w:/apache/site/htdocs/401.
...
all im wanting for now is to get the error pages shown if an error occures.
ASKER
thank you
sean
sean
ASKER
ok what would you suggest doing in my case to show tidy URL of error pages?