Title: mod_rewrite: remove string
Last modified: August 18, 2016

---

# mod_rewrite: remove string

 *  Resolved [Sebastian](https://wordpress.org/support/users/sebstein/)
 * (@sebstein)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/mod_rewrite-remove-string/)
 * Hi folks,
 * I’m currently migrating my blog to wordpress. Seems to work just fine, but I 
   also want to migrate some of my old permalinks, because there are some links 
   in the net pointing at them. Basically, it should be possible to do with mod_rewrite,
   but I can’t get it working.
 * Example of old permalink:
 * [http://domain/blog/fixedstring/variablestring/2007/05/01/entry](http://domain/blog/fixedstring/variablestring/2007/05/01/entry)
 * Same post with new permalink:
 * [http://domain/2007/05/01/entry](http://domain/2007/05/01/entry)
 * So basically I have to remove “blog/fixedstring/variablestring/”. I would write
   the following rule:
 * (^blog/fixedstring/.[a-z]*/)(.*) $2
 * This works, if I use it outside of wordpress, but I don’t know how to integrate
   it with the standard wordpress .htaccess file. I thought it must work as follows:
 *     ```
       # BEGIN WordPress
       <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /
       RewriteRule (^blog/fixedstring/.[a-z]*/)(.*) $2
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule . /index.php [L]
       </IfModule>
   
       # END WordPress
       ```
   
 * Does anybody knows what is going wrong?
 * Regards,
 * Sebastian

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

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 1 month ago](https://wordpress.org/support/topic/mod_rewrite-remove-string/#post-558259)
 * Try this instead:
 *     ```
       RewriteRule (^blog/fixedstring/.[a-z]*/)(.*) $2 [R=301,L]
   
       # BEGIN WordPress
       <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule . /index.php [L]
       </IfModule>
   
       # END WordPress
       ```
   
 * You really never want to change WordPress’s rules directly. Consider the text
   between BEGIN and END to be inviolate unless you really, really know what you’re
   doing. 😉
 *  Thread Starter [Sebastian](https://wordpress.org/support/users/sebstein/)
 * (@sebstein)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/mod_rewrite-remove-string/#post-558393)
 * I think the [R=301,L] at the end did the trick, because I already tried it with
   out it. So what does it actually do? Can I use several rules, for example to 
   rewrite the old feed URL?
 * Sebastian
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 1 month ago](https://wordpress.org/support/topic/mod_rewrite-remove-string/#post-558431)
 * R=301 causes it to send a redirect to the browser, changing their URL. The reason
   for the 301 is to say that it’s a Permanent Redirect. This allows search engines
   to recognize that your URL has changed and update themselves accordingly. Without
   the =301 it would send a 302 (by default) and that’s a Temporary Redirect.
 * The L makes it the Last rule in the processing chain. Once it hits that, it stops
   processing. For a redirect, you almost always want an L in there to stop the 
   server processing and immediately force the user to the new URL.
 * You may want to read the [documentation for mod_rewrite](http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html).

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

The topic ‘mod_rewrite: remove string’ 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: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 2 participants
 * Last reply from: [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * Last activity: [19 years, 1 month ago](https://wordpress.org/support/topic/mod_rewrite-remove-string/#post-558431)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
