-2

Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

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

7
  • to see the problem what i want result is i need some thing to redirect if some one types wrong url just check the link even if you delete half of the location at the endof url it still opens adsbuz.com/classifieds/abu-dhabi-uae
    – david
    Sep 3, 2012 at 19:17
  • I tried that and got what appears to be a 404 page with an advanced search form on it. Sep 3, 2012 at 21:02
  • How is this different to your question from 5 days ago? serverfault.com/questions/423124/… - and from 6 days ago? serverfault.com/questions/422643/… - both of which have good answers which you have provided no feedback to. Sep 3, 2012 at 21:32
  • if you check there i already told that its not working for me else the comments are deleted ok now come to the point dont take it wrong that why i posted it again after 5 days with no results i thought maybe my question is burried so i just started new one to get quick help if its wrong than i am sorry for that but iraelly need some thing quick solution 1#to see the problem what i want result is i need some thing to redirect if some one types wrong url just check the link even if you delete half of the location at the endof url it still opens adsbuz.com/classifieds/abu-dhabi-uae
    – david
    Sep 3, 2012 at 21:44
  • and secound above question help its not the matter of single page i know how to do it its the whole directory thanks and i hope you dont mind
    – david
    Sep 3, 2012 at 21:47

2 Answers 2

0

You don't seem to have an actual RewriteRule in place.

RewriteCond %{REQUEST_URI} ^/vehicle-cars/
RewriteRule ^/vehicle-cars/(.*)$ /vehicle-cars-for-sale/$1 [L]
5
  • this thing is not doing anything both the url are opening with out any redirect any how thanks but please need some thing else
    – david
    Sep 3, 2012 at 21:34
  • here is my .htaccess file with more details # Use PHP5 Single php.ini as default AddHandler application/x-httpd-php5s .php ErrorDocument 404 /content/404.php <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^www\.adsbuz\.com$ [NC] RewriteRule ^(.*)$ adsbuz.com/$1 [R=301,L] RewriteCond %{THE_REQUEST} ^.*/vehicles-cars\.php RewriteCond %{REQUEST_URI} ^/vehicle-cars/ RewriteRule ^/vehicle-cars/(.*)$ /vehicle-cars-for-sale/$1 [L]
    – david
    Sep 3, 2012 at 21:36
  • Check your Apache log to see what's happening. You may need to increase the debug level for that. Sep 3, 2012 at 21:41
  • how to or from where to increase debug level thanks
    – david
    Sep 6, 2012 at 11:32
  • You change the LogLevel in the site configuration and run apache2ctl -k restart. The default log level is warn. Change it to notice, info, or even debug to get more information. The lower the log level, the more information is logged, so make sure you don't set the level too low, or you will drown in information. Sep 6, 2012 at 12:05
0

Take a look at my answer

Redirecting Old Invalid URL's using PHP and .htaccess

2
  • sir i dont understand can you please explain it little bit more thanks
    – david
    Sep 3, 2012 at 21:48
  • there is already ErrorDocument 404 /content/404.php as you can see in .htaccess file so whats the difference i don't understand can you please explain it little bit thanks for your response
    – david
    Sep 6, 2012 at 11:35

Not the answer you're looking for? Browse other questions tagged .