Redirecting 404 error with .htaccess via 301 for SEO etc

前端 未结 2 872
野的像风
野的像风 2020-12-07 20:51

I couldn\'t find a straight answer to my question and need to know it from the real experts.

I had a website which urls were generated by Joomla. I believe that tons

相关标签:
2条回答
  • 2020-12-07 21:29

    You will need to know something about the URLs, like do they have a specific directory or some query string element because you have to match for something. Otherwise you will have to redirect on the 404. If this is what is required then do something like this in your .htaccess:

    ErrorDocument 404 /index.php
    

    An error page redirect must be relative to root so you cannot use www.mydomain.com.

    If you have a pattern to match too then use 301 instead of 302 because 301 is permanent and 302 is temporary. A 301 will get the old URLs removed from the search engines and the 302 will not.

    Mod Rewrite Reference: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

    0 讨论(0)
  • 2020-12-07 21:34

    I came up with the solution and posted it on my blog

    http://web.archive.org/web/20130310123646/http://onlinemarketingexperts.com.au/2013/01/how-to-permanently-redirect-301-all-404-missing-pages-in-htaccess/

    here is the htaccess code also

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . / [L,R=301]
    

    but I posted other solutions on my blog too, it depends what you need really

    0 讨论(0)
提交回复
热议问题