Recent Topics

1 Sep 11, 2006 16:49    

I was following along with the old [url=http://forums.b2evolution.net/viewtopic.php?t=1564]Remove ".php" from your blogs (advanced stuff)[/url] method of using stub files, and I think I've improved on it.

This version does not require you to explicitly define the names of your blogs nor to modify your htaccess file every time you create a new blog. It works with and without stub files and static files (though it's most efficient when you use one or the other)

To use:

Step 1 - copy the following into your .htaccess file in your b2evolution folder (or create a new .htaccess file if you don't have one yet)

RewriteEngine On

# If we have an static html file for the bare subject (no extra path, no query string), use it:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} ^(/blogs/([^/]+))/?$
RewriteCond %{DOCUMENT_ROOT}%1.html -f
RewriteRule ^([^/\?]+)(/?(.*))?$ %2.html [L]

# If we have a stub file for the subject, use it:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^(/blogs/([^/]+))(/?(.*))?$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^([^/\?]+)(/?(.*))?$ %2.php$2 [L]

# If there is no static file and no stub file, call b2evo!
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)(/(.*))?$ /blogs/index.php/$1/$3 [R=PERMANENT,NC,L]

This assumes that your b2evolution install is in the /blogs/ folder off of the root of your website. If not, just modify the code above to replace all instances of "/blogs/" with the correct path (from the root of your website).

I've been testing it out over the last weekend and it seems to be working OK. If you have any problems with it let me know and I'll see if there is a fix or workaround.

2 Nov 10, 2006 19:01

Hello xangelusx !!

Sorry to bother you, but I seem to have difficulties with my .htaccess file, and since you seem to know much more about it, I though I could ask you:

Carrying on from a previous thread ( http://forums.b2evolution.net/viewtopic.php?p=46473&highlight=#46473 ), I managed to add a line from your code, and it has improved it.

This is my current situation: ( the blog in question is: aldo)

- I create a new blog with Autoblog, and the new user is correctly [u]redirected[/u] to his new blog: www/blogs/username.
- Furthermore, all [u]the links[/u] are correctly displaying the address that should be: www/blogs/username.
- However, the only way to access the blog is by entering on [u]the address bar[/u]: www/blogs/index.php/username.

I use stub files, and the folder I use for them is called: blog

This is a copy of my .htaccess file:

# this will select the default blog template to be displayed
# if the URL is just .../blogs/
<IfModule mod_dir.c>
   DirectoryIndex index.php index.html
</IfModule>


# this will make register globals off in b2's directory
# just put a '#' sign before these three lines if you don't want that
<IfModule mod_php4.c>
   php_flag register_globals off
</IfModule>

Options +FollowSymlinks
RewriteEngine On

# Replace "blogs/" with whatever your Stub Storage Folder is called in Autoblog Plugin. Example: "mystorage/"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(/blog/([^/]+))(/?(.*))?$
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^([^/\?]+)(/?(.*))?$ %2.php$2 [L]


I wonder if you could help me please.

Thank you

3 Nov 13, 2006 20:20

Just so we're clear, my understanding of htaccess only came after a full 12 hours of trial-and-error :) That said, I think you are forgetting to add "/blog/" to the beginning of the redirection, no?

RewriteRule ^([^/\?]+)(/?(.*))?$ /blog/%2.php$2 [L] 

Also, in your B2evolution back office, check your blog settings - some of the blog URL parameter fields can be tricky. I've attached a screenshot of how my main blog is set up. You'll probably want to make sure your settings match. Then under the apps setting tab. make sure the Use Extra Path Info is checked (see second screenshot)

Hope this helps more than hurts. Be sure to backup your database and current htaccess file first, just in case I am completely and totally wrong.

5 Nov 13, 2006 20:45

PPS: Check your server's error log files if you are still having trouble. They may help you refine your redirection expressions.

6 Nov 13, 2006 22:21

woaw :) Thank you xangelusx !!!

I'll try all these concise instructions and be back here to let you know What the outcome is.

Just so we're clear, my understanding of htaccess only came after a full 12 hours of trial-and-error

Pretty good though (compared to me :)) )

=> Thanks again very much.


Form is loading...