Elliott C. Back: Technology FTW!

Moving the root, but not sub-queries

Posted in Mod_Rewrite by Elliott Back on October 24th, 2004.

This is an example of using mod_rewrite to move the root of your document, but not any scripts handling queries deeper down. In my case, I have an old bblog blog that I want to move, but I don’t want to suddenly break all of my old posts. This rule will rewrite any URL ending in blog or blog/, as long as the request string is null. Then it forwards you with HTTP code 301 (Permanently moved) to this blog address.

RewriteEngine On
RewriteCond %{REQUEST_URI} blog[/]*$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ http://elliottback.com/wp/ [R=301]

This second rule simply redirects requests from the old RSS URL to the new WordPress URL. For the few people that syndicate that, they won’t even notice the change in platform!

RewriteCond %{REQUEST_URI} blog/rss.php(.*)$
RewriteRule ^(.*)$ http://elliottback.com/wp/feed/rss2/

This entry was posted on Sunday, October 24th, 2004 at 8:28 pm and is tagged with request string, query string, request uri, bblog, queries, scripts, syndicate. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback.

Viewing 6 Comments

 

Trackbacks

(Trackback URL)

  • [Netzwech.de]

    4/21/2005 at 10:32 am

    Bblog zu wordpress Artikel umschreiben Klare Urls zu erstellen ist Suchmaschinen freundlich und mit mod_rewrite des Apache Webserversleicht gemacht. Um nicht ...

close Reblog this comment
blog comments powered by Disqus