Title: Redirection/Modifying htaccess
Last modified: August 18, 2016

---

# Redirection/Modifying htaccess

 *  Resolved [phileplanet](https://wordpress.org/support/users/phileplanet/)
 * (@phileplanet)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/)
 * I’ve searched the site but I can’t find a clear answer to this.
 * What is the proper way to edit the WP .htaccess file without messing up WP? Meaning
   do I edit inside “# BEGIN WordPress” & “# END WordPress”, after, before…
 * I basically want to add mod_rewrite rules to 301 redirect pages from my old site
   to posts in WP. I’ve tried three plugins but they don’t seem to work well.

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

 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435689)
 * I think you can add your stuff either above the # BEGIN WordPress or below # 
   END WordPress. Don’t leave the .htaccess writeable once you’ve edited though!
 *  Thread Starter [phileplanet](https://wordpress.org/support/users/phileplanet/)
 * (@phileplanet)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435702)
 * Okay that doesn’t mess up WP, which is good, but my redirects don’t seem to do
   anything.
 * Here is the htaccess:
    `# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine
   On RewriteBase /area51blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{
   REQUEST_FILENAME} !-d RewriteRule . /area51blog/index.php [L] </IfModule>
 * # END WordPress
 * RewriteRule ^sites.php$ /links/ [R=301]
 * Is there something wrong?
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435746)
 * You need to add it above the WordPress rules because WordPress will hijack pretty
   much everything that isn’t a real folder or file or whatnot. 😉
 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435748)
 * Ah, didn’t realize that. Thanks for that info, Viper!
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435752)
 * I believe these three lines say that if it isn’t a real file or directory, then
   give the URL to WordPress’ index.php file:
 * `RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d RewriteRule./
   area51blog/index.php [L]
 * So if you want to avoid that, you gotta handle it before it gets given to WordPress.
   🙂
 * > Don’t leave the .htaccess writeable once you’ve edited though!
 * For security or so that WordPress won’t overwrite it? If it’s the latter, then
   there’s no need to worry. That’s the whole point of the `# BEGIN WordPress` and`#
   END WordPress`. When WordPress regenerates it’s rules, it only replaces the stuff
   inbetween those two lines. So as long as your custom stuff is outside of them,
   they won’t be touched. 😉
 *  [vkaryl](https://wordpress.org/support/users/vkaryl/)
 * (@vkaryl)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435762)
 * For security….
 *  Thread Starter [phileplanet](https://wordpress.org/support/users/phileplanet/)
 * (@phileplanet)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435767)
 * Sorry but it’s still having no effect.
    Here’s the new .htaccess: `RewriteEngine
   on RewriteRule ^links.php$ /links/ [R=301]
 * # BEGIN WordPress
    <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /area51blog/
   RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule./
   area51blog/index.php [L] </IfModule>
 * # END WordPress
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435802)
 * `RewriteRule ^links.php?$ /links/ [QSA,L]`
 *  Thread Starter [phileplanet](https://wordpress.org/support/users/phileplanet/)
 * (@phileplanet)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-435965)
 * Sorry Viper007Bond but I wanted it to redirect links.php to /links/, not rewrite.
 * I meant that I was using mod_rewrite to redirect since most plugins didn’t really
   work well for me.
 *  [viper007bond](https://wordpress.org/support/users/viper007bond/)
 * (@viper007bond)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-436129)
 * Well I’m a `mod_rewrite` idiot, so I usually just use the full URL instead then:
 * `RewriteRule ^links.php?$ http://yoursite.com/links/ [QSA,L]`
 *  Thread Starter [phileplanet](https://wordpress.org/support/users/phileplanet/)
 * (@phileplanet)
 * [19 years, 8 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-436365)
 * Okay I haven’t found an htaccess solution to this so what I am going to do is
   include a PHP script in the 404 template.
 * The script basically sees takes the URL of the 404, and if it matches a location
   in my redirects, it goes to the new location.
 * I hope to make this a plugin with a user interface so that others can benefit
   from it.
 * Thanks for your help.

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

The topic ‘Redirection/Modifying htaccess’ is closed to new replies.

## Tags

 * [htaccess](https://wordpress.org/support/topic-tag/htaccess/)
 * [mod_rewrite](https://wordpress.org/support/topic-tag/mod_rewrite/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 11 replies
 * 3 participants
 * Last reply from: [phileplanet](https://wordpress.org/support/users/phileplanet/)
 * Last activity: [19 years, 8 months ago](https://wordpress.org/support/topic/redirectionmodifying-htaccess/#post-436365)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
