Forum Moderators: phranque
And it works, I am now trying to make a simple redirection so that whoever tries to brows errors/ would be automatically redirected to errors/403/
Suggestions please?
And one more thing.
I asked before about double slash // issue..
I have found a solution but its still a simple problem...
RewriteCond %{REQUEST_URI} ^//+(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*/)/+$ [OR]
RewriteCond %{REQUEST_URI} ^/(([^/]+/)*)/+$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)//+(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/([^/]+)//+(.*)$
#RewriteRule / [domain.com...] [R=301,L]
The above works with every // but the very first one under one condition.
Means
[site.name...] <---
only when double slash before and nothing after, I can't handle it.
Can you help me fix this please?
Regards,
[edited by: Saturn at 10:29 pm (utc) on Aug. 15, 2007]
ErrorDocument 403 /errors/403/
ErrorDocument 404 /errors/404/
# Rewrite error pages to index.php with error code in query string
RewriteRule ^errors/(400¦401¦403¦404¦500)/$ index.php?error=$1 [L]
#
# Prevent direct client access to error pages (except for 403)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /errors/
RewriteRule %{REQUEST_URI} !^/errors/403/
RewriteRule ^errors/ - [F]
#
# Prevent direct client access to error-handling script
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?error=
RewriteRule ^index\.php$ - [F]
To clarify, a typical value of THE_REQUEST would look like this:
GET /index.php?page=1&sort=ascending HTTP/1.1(This example was chosen to show all the "parts" -- not because the URL is in any way relevant to your site.)
Be aware that you could eliminate the need for the first two rules by defining your error documents like this:
ErrorDocument 403 /index.php?error=403
ErrorDocument 404 /index.php?error=404
# Prevent direct client access to error-handling script
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?error=
RewriteCond %{QUERY_STRING} !^error=403$
RewriteRule ^index\.php$ - [F]
To avoid this, critical error handlers should be plain, static-HTML documents with no external dependencies -- No images, no external scripts, no external CSS -- completely self-contained. And to those who say that they want all their pages to "fit their template" and to "match their site's 'look and feel'", I say, "It's an error page! It'll stink when anyone sees it, no matter how pretty it is!" Or, as someone else posted here very recently, "You can't put lipstick on a pig!" ;)
For a redirect to fix double slashes, see: [webmasterworld.com...]
Jim
I have followed your instructions as follows.
ErrorDocument 400 /errors/400/
ErrorDocument 401 /errors/401/
ErrorDocument 403 /errors/403/
ErrorDocument 404 /errors/404/
ErrorDocument 500 /errors/500/
# Rewrite error pages to index.php with error code in query string
RewriteRule ^errors/(400¦401¦403¦404¦500)/$ index.php?mIRCdotOrgPageID=$1 [L]
# Prevent direct client access to error pages (except for 403)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /errors/
RewriteRule %{REQUEST_URI}!^/errors/403/
RewriteRule ^errors/ - [F]
#
# Prevent direct client access to error-handling script
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?error=
RewriteRule ^index\.php$ - [F]
But still, no redirecting at all. I am testing locally, when I try [localhost...] I get no redirecting and I also get the default apache error page, I wonder why I am not getting the custom page (could be xampp) I am not sure.
Note: I assume you are aware I do NOT have a folder named errors, I am using mod_rewrite.
---
Forbidden
You don't have permission to access /site/errors/ on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.0 (Win32) DAV/2 mod_ssl/2.2.0 OpenSSL/0.9.8a mod_autoindex_color PHP/5.1.1 Server at localhost Port 80
---
That didn't completely fix my issue [localhost...] <-- note the two slashes?
I can still use as many slashes as I want starting the string...
ForbiddenYou don't have permission to access /site/errors/ on this server.
You'll need to fix that first, before worrying about multiple slashes. Keep your code simple, get it working one small step at a time, and then add the 'fancy decorations' later.
Comment out the entire ruleset that forbids access to your index.php?error=4xx URLs, flush your cache, test, and let us know the result.
Jim