404 pages to known page

Discuss practical ways rearrange URLs using mod_rewrite.

404 pages to known page

Postby xtraoss » Tue Nov 18, 2008 3:43 pm

hi

i need to redirect all 404 pages on my domain and any other error pages 400 401 403 403 500 to the same page lets say the home page

i all ready use modrewrite on my joomla site and also use sef urls using the standard joomla sef not out side component or else

my domain if it's ok to say is http://www.xtraoss.com

thanks in advance
xtraoss
 
Posts: 11
Joined: Sun Nov 02, 2008 3:14 am
Location: Cairo, Egypt

Postby richardk » Wed Nov 19, 2008 7:31 am

Use ErrorDocument. For example
Code: Select all
ErrorDocument 404 http://www.example.com/


Read the documentation before you do this, it is not a good idea to do this for some errors.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby xtraoss » Wed Nov 19, 2008 8:00 am

Hi

Read the documentation before you do this, it is not a good idea to do this for some errors.


thank you for your help

do you mean the other errors or for 404

all i want is to not get that error to appear in my site
using sef urls points to contents that no longer found in my site but it appear on Google and Google reports them as 404 links or error

should i use the given code or it will cause problems ?

thanks
xtraoss
 
Posts: 11
Joined: Sun Nov 02, 2008 3:14 am
Location: Cairo, Egypt

Postby richardk » Wed Nov 19, 2008 9:27 am

401 as an example
In addition, if you use a remote URL in an ErrorDocument 401, the client will not know to prompt the user for a password since it will not receive the 401 status code. Therefore, if you use an ErrorDocument 401 directive then it must refer to a local document.


A 404 error is for pages that no longer exist. If you want SEO advice i cannopt help you.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby xtraoss » Wed Nov 19, 2008 10:06 am

thanks a lot

so i must redirect 404 error to local document not to the root of my site ?
so i can make a 404.htm file to point to rather than to the root ?

is that corrrect

and what in such case is the code to but it in my .htaccess file
and should i but that code before or after my sef codes

thanks
xtraoss
 
Posts: 11
Joined: Sun Nov 02, 2008 3:14 am
Location: Cairo, Egypt

Postby richardk » Thu Nov 20, 2008 1:37 pm

You don't have to do anything. Do the redirect if you want the redirect.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby xtraoss » Thu Nov 20, 2008 3:23 pm

hi

i used the code to redirect the 404 error page to the root
but it didnot work for me and i still get the usual 404 error page

any help
xtraoss
 
Posts: 11
Joined: Sun Nov 02, 2008 3:14 am
Location: Cairo, Egypt

Postby richardk » Fri Nov 21, 2008 12:58 pm

The ErrorDocument line does not work?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule . http://www.example.com/ [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby xtraoss » Fri Nov 21, 2008 2:23 pm

hi

the code did not work for me

i have this codes in my .htaccess file :

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

so what else can i do ?

thanks
xtraoss
 
Posts: 11
Joined: Sun Nov 02, 2008 3:14 am
Location: Cairo, Egypt

Postby richardk » Sun Nov 23, 2008 9:20 am

All (most) 404 pages are already sent to index.php. You would need to do the redirect in the PHP instead.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Next

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: Google [Bot] and 22 guests

cron