Question

I want to Redirect this 404 error URL to a Static URL. How this is possible. Please help..

URL http://www.takeshiyashima.com

/us/my-blog?catid=1&id=404:my-thought-of-the-day-problem-of-traditional-education  
/ja/resources?id=366:video-clip  
/ja/resources?id=364:mortgage-reset-second-big-wave 
/us/my-blog/65-investment?catid=230&id=230:wealth-cycle9 
/us/resources?catid=72&id=354:fractional-reserve-banking
/us/my-blog?catid=1&id=432:petrodollar-system-inevitable-economic-collapse-and-possibility-of-world-war-iii 
/tw/?catid=0&id=539 
/tw/?catid=0&id=519 
/ja/resources?catid=72&id=357:flaw-of-401k 
/us/my-blog/65-investment?catid=301&id=301:my-recent-real-estate-deal-and-why-i-am-investing-in-real-estate 
/tw/?catid=0&id=502
/ja/?catid=0&id=516 

I have 561 error in google webmaster. Please help me to redirect this type of URL.

Était-ce utile?

La solution

If you want to, say, redirect all requests for a non-existent page to http://example.com/404.php, just add the following line to your .htaccess file:

ErrorDocument 404 http://example.com/404.php

However, it's often better to serve 404.php page without visibly changing the URL. This is even easier:

ErrorDocument 404 /404.php

Note that, with the latter solution, those pages will still show up as 404 errors e.g. in Google's webmaster tools. However, that is actually a good thing, since it lets you tell missing pages apart from redirects. Users visiting those pages will still see your 404.php page, just served under the missing page's URL, and with a 404 status code.

For more information, see Custom Error Responses in the Apache documentation.


Ps. Note that this will not work if your 404 errors are generated by some application framework or script (i.e. the script is successfully executed, but deliberately returns a 404 response, e.g. because it can't find the requested resource in the database). In that case, the solution will depend on the specific application or script.

Autres conseils

use .htaccess redirection

ErrorDocument 404 http://example.com/404/

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /pages/errors/404.php [L]

Blog: Redirect your 404 error to a Custom Page
Answer on Stack Overflow

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top