July 2010
M T W T F S S
« Jun    
 1234
567891011
12131415161718
19202122232425
262728293031  
86

Categories

Archives

How to hide a Worpress instance behind a different Apache server with mod_rewrite

After playing around with wordpress for a week I finally figured out how to get it working behind a reverse proxy with Apache between 2 machines. In this scenario SERVER A is connected to the internet, while SERVER B is on the local intranet only.

Step 1: Apache modifications on the internet facing box (SERVER A)
1
2
3
4
5
6
7
8
<VirtualHost *:80>
  UseCanonicalName Off
 
  RewriteEngine On
  ServerName www.lamolabs.org
  RewriteRule ^/blog/(.*) http://machineB/blog/$1 [P,L]
  ProxyPassReverse /blog/ http://machineB/blog/
</VirtualHost>
1
% /etc/init.d/httpd reload
Step 2: Apache modifications on the intranet box (SERVER B)

NOTE: wordpress is installed under “/var/www/html/apps/wordpress/current” on SERVER B

1
2
3
4
5
6
7
8
<VirtualHost *:80>
  UseCanonicalName off
  ServerName www.lamolabs.org
  ServerAlias machineB
 
  RewriteEngine on
  RewriteRule ^/blog/(.*) /apps/wordpress/current/$1 [L]
</VirtualHost>
1
% /etc/init.d/httpd reload

Step 3: Configure Wordpress
  1. first login to …/wp-admin/
  2. click on Settings -> General
  3. change the Wordpress address (URL) to “http://www.lamolabs.org/blog”
  4. change the the Blog address (URL) to “http://www.lamolabs.org/blog”
  5. click on Settings -> Permalinks
  6. change to the Custom Structure and set it to “/%post_id%/%postname%/”
  7. Save Settings

Should now be able to access the wordpress blog at lamolab’s blog

useful links
  1. - Changing The Site URL in wordpress
  2. - Apache mod_rewrite examples

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>