Archive

Posts Tagged ‘wordpress’

Using WordPress 2.8 and up with a proxy webserver in front

June 12th, 2009 No comments

I use a public plain apache server with mod_rewrite to serve my wordpress as i don’t trust php enough to expose it to the world ;-)

I wrote and updated a previous post describing what i’ve done to make things work for me, but now with WordPress 2.8 it’s broken, so i had to figure out a fix for this problem again. This is how i’ve done it:

on my public webserver i use this line in the virtual host config:

?View Code APACHE
1
RewriteRule ^(.*)$ http://sotf.labnet.uclv.net/wordpress$1 [L,P]

The magic is done in my wp-config.php file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* That's all, stop editing! Happy blogging. */
 
// hack for using wordpress behind another apache / mod_rewrite
// config hack:
// set subdir of this worpress installation absolute to this webserver (normally /wordpress)
$local_subdir = '/wordpress';
// set subdir on remote server (normally /)
$remote_subdir = '/';
 
//print_r($_SERVER);
if ( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
$old_host = $_SERVER['HTTP_HOST'];
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
$_SERVER['SCRIPT_URI'] = str_replace($old_host, $_SERVER['HTTP_X_FORWARDED_HOST'], $_SERVER['SCRIPT_URI']);
}
$_SERVER['REQUEST_URI'] = str_replace($local_subdir.'/', $remote_subdir, $_SERVER['REQUEST_URI']);
$_SERVER['SCRIPT_URL'] = str_replace($local_subdir.'/', $remote_subdir, $_SERVER['SCRIPT_URL']);
$_SERVER['SCRIPT_URI'] = str_replace($local_subdir.'/', $remote_subdir, $_SERVER['SCRIPT_URI']);
$_SERVER['SCRIPT_NAME'] = str_replace($local_subdir.'/', $remote_subdir, $_SERVER['SCRIPT_NAME']);
$_SERVER['PHP_SELF'] = str_replace($local_subdir.'/', $remote_subdir, $_SERVER['PHP_SELF']);
// end of hack
 
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . 'wp-settings.php');

IMPORTANT: the hacking of the $_SERVER variables has to be done before requiring wp-settings.php!

Update

I had some trouble that rewriting pretty permalinks didn’t work at first. The problem was that I had to enable the use of .htaccess for my wordpress directory in the apache config of my local server:

?View Code APACHE
1
2
3
<Directory /data01/www/wolfgang.reutz.at />
 AllowOverride FileInfo
</Directory>

And i had to enter the public webaddress into both of the blog url fields in the general settings of the wordpress admin interface. After that i had to manually tweak my .htaccess file in my wordpress installation:

?View Code APACHE
1
2
3
4
5
6
7
# BEGIN WordPress
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
# END WordPress
Categories: Webdev Tags: ,

How to hide a worpress instance behind a different apache server with mod_rewrite

August 22nd, 2008 No comments

I had the need to move my blog running wordpress 2.0.x to a different server, but keeping the domain name on the “old” server. I used mod_rewrite and with a lot of trial and error and some updates i finally got this working solution:
Read more…

Anarchy Media Player

September 10th, 2007 No comments

As you might already know, Anarchy Media Player is a way cool javascript-based player solution for playback of media files like .mp3, quicktime movies, flash movies and so on. The very cool thing about that is, all you have to do is to include the anarchy player javascript file into your html document and each and every link to a file ending with .mp3, .mov, .wmv, .flv, … will be magically converted into a media player (thanks to the HTML DOM and javascript ;-) ).

I use the 1.6.5 version and found that when you add a class with “amplink” to your link, the media player will ignore this link! This comes handy if you want to explicitly put a link to a movie file for which you don’t want the mediaplayer magic to happen. Imagine you have a link to a flash video and two links for quicktime movies in high and low quality for download. The link to the .flv should be converted into a media player, the two quicktime links should be left intact – just put a “amplink” class on the two quicktime links and you’re set!

Categories: Webdev Tags: , ,