Title: .htaccess redirect code
Last modified: March 29, 2019

---

# .htaccess redirect code

 *  [nightdark](https://wordpress.org/support/users/nightdark/)
 * (@nightdark)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/htaccess-redirect-code/)
 * 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](https://wordpress.org/support/users/nightdark/).

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

 *  [Santiago](https://wordpress.org/support/users/sjaure/)
 * (@sjaure)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/htaccess-redirect-code/#post-11372653)
 * Hi [@nightdark](https://wordpress.org/support/users/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](https://stackoverflow.com/questions/12237579/how-to-use-errordocument-404-with-301-in-header)
 * Hope this helps.
    Cheers
 *  [MarkRH](https://wordpress.org/support/users/markrh/)
 * (@markrh)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/htaccess-redirect-code/#post-11372923)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [MarkRH](https://wordpress.org/support/users/markrh/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/htaccess-redirect-code/#post-11372923)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
