Recent Topics

1 Jan 08, 2005 20:19    

Since individual blogs on b2evolution can accessed like:

mydomain.com/b2evo/index.php/blog1
hisdomain.com/b2evo/index.php/blog2
herdomain.com/b2evo/index.php/blog3

I'm trying to use Apache's mod_alias and mod_rewrite to make it so URLs like this can be used:

mydomain.com/b2evo/blog/blog1
hisdomain.com/b2evo/blog/blog2
herdomain.com/b2evo/blog/blog3

I created an Alias:

Alias /b2evo /var/www/html/b2evo

and some mod_rewrite directives:

<Directory /var/www/html/b2evo>
RewriteEngine On
RewriteBase /b2evo
RewriteRule ^blog/(.+)$ index.php/$1
</Directory>

However, it doesn't work. I've tried various RewriteRule flags (L, PT, NS, etc.) and the best I can get is the request is rewritten to "index.php" - for some reason the "/blogX" is stripped on the internal redirect apache performs. Has anybody been able to get something like this to work? Seems like it'd be a great way to avoid having to create a bunch of stub files.

2 Jan 08, 2005 20:24

I also tried this, but it doesn't work either:

AliasMatch /b2evo/blog/(.+) /var/www/html/b2evo/index.php/$1

3 May 21, 2005 02:22

I'm not much for mod_alias, but I know a thing or two about mod_rewrite. This would get the proper file loaded:

RewriteEngine On
# If the subject/extrapath does not match an existing file, call b2evo!
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^b2evo/blog/(blog1|blog2|blog3)(/.*)?$ b2evo/index.php

# If no blog is called, then call index.php
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^b2evo/blog b2evo/index.php

It won't work because b2evo is looking at $_SERVER['REQUEST_URI'] to determine which blog to load, and even though you've told Apache which file to load, you haven't set the REQUEST_URI properly to have b2evo know what to do with it.

Try putting this at the top of your index.php, along with the .htaccess above:

$_SERVER['REQUEST_URI'] = preg_replace('#^/b2evo/blog#', '/b2evo/index.php', $_SERVER['REQUEST_URI']);

Does that work?


Form is loading...