Moving the root, but not sub-queries
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. |
7 Responses to “Moving the root, but not sub-queries”
Leave a Reply
Excellent – thanks for this info! I’ve spent the last half hour trying to figure out how to redirect from the root and failed miserably – this works great
That’s the easy part, Elliott.
I mean, incorporating an RSS feed from another blog into a header-style section like your “Today’s Links”
I’ll look around some more, I think. I’ve written an RSS parser in PHP for Audioscrobbler and somewhat integrated it into Wordpress, I could probably roll my own plugin if I had to.
Hey JWK–Wordpress publishes an RSS feed to http:// your-wordpress-site . com / wordpress-directory / feed / which you can use to syndicate the site. Most themes and templates also have an RSS link somewhere…
Speaking of syndication, I haven’t been able to find any good way to syndicate sites using WordPress. Any ideas?
Bblog zu wordpress Artikel umschreiben
Klare Urls zu erstellen ist Suchmaschinen freundlich und mit mod_rewrite des Apache Webserversleicht gemacht. Um nicht alle alten Artikel von Bblog ins nichts verweisen zu lassen habe ich in der .htaccess Datei dann folgende Regel eingefügt:
Rewrit…
Check out the default .htaccess rules that ship with wordpress. Modifying one could solve your problem, assuming the WP and bblog post_ids were the same:
RewriteRule ^item/([0-9]+)?/?$ /wp/index.php?p=$1
I’ve verified that this works–hope it helps.
Hmm, i used bblog too and i installed into my htdocs root.
And i used the clean-url .htaccess of bblog. So the url looks like http://www.netzwech.de/item/42
How can i rewrite it to my wordpress installation? Your example doesnt work
Any hints?