404 Autoredirection

Started by akheir, March 26, 2008, 08:39:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

akheir

Ok - I know this must be simple, but I can't seem to get it working right on my own site - works on others!!! :)

How do I get a 404 to auto-redirect to the base url?  I added ErrorDocument 404 / to the .htaccess file, but I get the following:

Quote
(Site Title)
We're sorry but the page you requested could not be found.
Return to site

Error 404

Any ideas?

Thanks.
Plan
Promote
Profit

Kheir Consulting
http://www.kheirconsulting.com

Jason

So any incorrect page request would route you back to the homepage?

Have you tried this to see if it works differently?

ErrorDocument 404 /index.php

(or .html -- whichever applies)

Have you tried uploading your own 404.shtml page to your account and have it set with a meta-refresh to go to wherever you want it?


akheir

Quote from: Jason
So any incorrect page request would route you back to the homepage?

Yes. :)

Quote from: Jason
Have you tried this to see if it works differently?

ErrorDocument 404 /index.php

(or .html -- whichever applies)

Makes no difference - still getting blocked. :(

Quote from: Jason
Have you tried uploading your own 404.shtml page to your account and have it set with a meta-refresh to go to wherever you want it?

Doesn't read the 404.shtml file.  :(

Any other ideas?

I think something is set up to block 404 redirection - my fault somewhere, but I can't figure out where! :o
Plan
Promote
Profit

Kheir Consulting
http://www.kheirconsulting.com

Jason

I haven't used it it in ages but last I recall, there's a "custom error pages" icon in cPanel -- is there anything there that may be conflicting for you? 

And there's nothing else in your .htaccess file that may be conflicting, right?

If not, let me know and I'll try some things with it tonight.

akheir

Quote
And there's nothing else in your .htaccess file that may be conflicting, right?

I didn't enter anything for the cPanel custom pages.  As for the .htaccess, it is based on a standard Joomla set.  Let me know if you see any problems. :)


##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On


#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla!/MamboDirectory (just / for root)

# RewriteBase /


########## Begin - Joomla! core SEF Section
############# Use this section if using ONLY Joomla! core SEF
## ALL (RewriteCond) lines in this section are only required if you actually
## have directories named 'content' or 'component' on your server
## If you do not have directories with these names, comment them out.
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
RewriteRule ^(content/|component/) index.php
#
########## End - Joomla! core SEF Section



########## Begin - 3rd Party SEF Section
############# Use this section if you are using a 3rd party (Non Joomla! core) SEF extension - e.g. OpenSEF, 404_SEF, 404SEFx, SEF Advance, etc
#
#RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
#RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule (.*) index.php
#
########## End - 3rd Party SEF Section



########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

ErrorDocument 404 /
Plan
Promote
Profit

Kheir Consulting
http://www.kheirconsulting.com

Mark

I would say it's probably best to use cPanel to create a page (that's what I did and it works) saying that the page is either missing or no longer available. Then, using the meta refresh, give the reader 10 or 15 seconds to read it before it redirects to the homepage.

That's probably the best way to do it because if you randomly redirect the user to the homepage without a message, they might get confused and try a few times to get to that URL because they don't know that it's no longer valid.

akheir

I understand that you don't want users to go to old pages again and again, but I have a dynamic site and many pages are deleted and I wanted to make sure that people are just automatically redirected to a valid page seamlessly.
Plan
Promote
Profit

Kheir Consulting
http://www.kheirconsulting.com

Jason

I tried to add a test 404 via cpanel and when I tried to test it on a fictional page, it returned an obviously custom one.  Did I try it on the wrong site? Did you figure it out already?

akheir

:)

Maybe I didn't explain right.  I am trying to get rid of that and just use an auto redirect.  Can't figure out how to eliminate it. :-\
Plan
Promote
Profit

Kheir Consulting
http://www.kheirconsulting.com

Jason

This is just a guess but judging by the formatting and "meta text" that your 404 appears to be using, my guess is that joomla is driving that...

Jason

I just renamed your current .htaccess and it used the "test" page I made so it's definitely your current .htaccess file that's serving the 404 you're seeing now.