[Techtalk] Mod Rewrite rules
Daniel Pittman
daniel at rimspace.net
Thu Sep 17 05:08:09 UTC 2009
Michelle Murrain <michelle at murrain.net> writes:
G'day Michelle. I see that no one has found an answer yet, so maybe I can
help out here:
> I have an interesting situation. I have two websites, one an old static HTML
> site (domain1.com), and the other a wordpress blog (domain2.com, that I am
> merging into one drupal site.
>
> domain1.com is already pointing to the new drupal site. I used a Drupal
> module, called Wordpress import, that took in all of my WP posts, and put
> them in drupal so that once I pointed domain2.com to the drupal site, all
> the URLs for the individual pages would work. Yay!
>
> One thing remains. The main page of the blog is at domain1.com/blog. I would
> like to redirect "domain2.com/" (and only that - no other pages below it) to
> point to /blog
>
> This is what I've got so far in my .htaccess file:
>
> RewriteCond %{HTTP_HOST} ^domain2.com$
> RewriteCond %{REQUEST_URI} =/
> RewriteRule ^/$ /blog/
>
> Alas, this doesn't work.
>
> Any tips?
Two tips: the first one is that I found it useful to use the RewriteLog option
when I was trying to debug similar problems in the past:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog
That will show you annoyingly verbose technical detail of the rewrite process,
but it can help point out why things are going wrong.
Second, if you are already using a VirtualHost directive at a higher level you
might find that using this is a bit easier than mod_rewrite:
<VirtualHost *:80>
ServerName domain2.com
RedirectMatch ^/+$ http://domain2.com/blog/
# ... etc
</VirtualHost>
Regards,
Daniel
--
✣ Daniel Pittman ✉ daniel at rimspace.net ☎ +61 401 155 707
♽ made with 100 percent post-consumer electrons
Looking for work? Love Perl? In Melbourne, Australia? We are hiring.
More information about the Techtalk
mailing list