how to rewrite or redirect old or missing or invalid url to 404 page

Posted by kath on Server Fault See other posts from Server Fault or by kath
Published on 2012-09-03T19:16:59Z Indexed on 2012/09/03 21:39 UTC
Read the original article Hit count: 258

Filed under:
|
|

I recently upgraded a site and almost all URLs have changed. I have redirected all of them (or so I hope) but it may be possible that some of them have slipped by me. Is there a way to somehow catch all invalid URLs and send the user to a certain page I am using PHP Thanks so much! error file is already in .htaccess but seems nothing going to change you can see the error file as below

AddHandler application/x-httpd-php5s .php
ErrorDocument 404 /content/404.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /

here are 2 different url one the first one is old one which i edited and the secound one is edited one

#1 old one (which is no longer on the server)

http://adsbuz.com/vehicles-cars/toyoya/2009-toyota-land-cruiser-gxr-4686.htm

#2 the editet one which is on the server

http://adsbuz.com/vehicles-cars-for-sale/toyoya/2009-toyota-land-cruiser-gxr-4686.htm

i need only the secound one with the vehicles-cars-for-sale because the other directory is already modified and its not on the server but as you can see after the (adsbuz) site name vehicles-cars and vehicles-cars-for-sale both are opening for same location

I hope I made myself clear

© Server Fault or respective owner

Related posts about php

Related posts about .htaccess