301 Redirects on any non existent image, pdf or url using .htaccess -


i have website updated , problem google bot indexes website gives lot of 404/500 errors when image not exist anymore or has been deleted. it's product catalogue website, products deleted , added on hourly basis.

i've tried rewriterule

^/(.*)$ /site/page/view/404 [r=301,l] 

which causes images on website not display more or

^(.*) /site/page/view/404 [r=301,l]  

which gives error 500 on browser.

is there way match non existent files/urls , redirect them permanently different url e.g. /site/page/view/404

try (assuming .htaccess in web root)

rewriteengine on rewritebase /  rewritecond %{request_filename} !-d   # not dir     rewritecond %{request_filename} !-f   # not file rewriterule ^.*$ /site/page/view/404 [r=301,l] 

alternatively, can use errordocument well.

errordocument 404 /site/page/view/404 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -