• hello
    i searched the google for redirect code for 404 pages to home page ( 301 redirects ) but didnt found

    also im using litespeed

    * i dont want use php code , just .htaccess !

    now using this plugin : 404 Redirection

    • This topic was modified 7 years, 2 months ago by nightdark.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @nightdark,
    I’m curious on why a php solution wouldn’t fit your needs.

    That said, you can try the following:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php [R=301]

    Found here:
    https://stackoverflow.com/questions/12237579/how-to-use-errordocument-404-with-301-in-header

    Hope this helps.
    Cheers

    Actually, that .htaccess code will cause all posts that use permalinks to fail and go to the main blog page instead, because those permalinks don’t physically exist as files or directories.

    So, WordPress actually needs to intercept requests that would normally generate a 404 first to see if they exist as a post with a certain permalink and then throw out a 404 response if it doesn’t exist.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘.htaccess redirect code’ is closed to new replies.