- b2evolution CMS Support Forums
- b2evolution Support
- FAQ
- Nice/clean/fancy urls in b2evolution
1 sam2kb Jan 19, 2009 01:11
Ok, here's a brief instructions on how to use "nice urls" in b2evo.
First of all, you need to create a .htaccess file (or add the code [u]at the end[/u] of existing file) in domain root directory e.g. /home/user/public_html/
Please note, if you installed b2evolution in subdirectory like _www.yoursite.com/sub/directory/blogs/ you need to edit the .htaccess file and uncomment the RewriteBase directive.
.htaccess file
#===============
# CATCH EVERYTHING INTO B2EVO:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
# Uncomment if you installed blogs in a subdirectory
# RewriteBase /sub/directory/blogs/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php
</IfModule>
Then follow the instructions
Single blog installation
Go to Blog settings > URLs and set the Absolute URL to: blog url without ending index.php (same as $baseurl selected upon installation)
It should look like "http://www.blog.com/", without quotes and [u]with[/u] an ending forward slash.
Multi-blog installation (same domain name)
Let's assume that b2evo base url is http://www.whatever.com
Default blog that match b2evo base URL
Go to Blog settings > URLs and select "Relative to baseurl" option (leave it empty)
Other blogs
Go to Blog settings > URLs and set the Absolute URL to b2evo base URL + path you like. Ideally the path should match "Blog URL name" value, but not necessarily.
ex: http://www.whatever.com/blogname/
[u]Don't forget about an ending forward slash.[/u]
##############################################
If you want or have to use stub files, do the following
Multi-blog installation (same domain name, stub files)
I presume you already use stub files to call each blog (default installation - blog1.php, blog2.php, blog6.php etc). For each blog set the "Absolute URL" to "http://www.blog.com/blog1/", "http://www.blog.com/blog2/" (use your own names, but make sure they match stub filename).
To remove the .php part from stub file names put the following code in .htaccess replacing blog1, blog2 etc. with the real names selected in Absolute URL.
.htaccess (multiple blogs with stub files)
#===============
# CATCH EVERYTHING INTO B2EVO:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
# Add new blogs here
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(blog1|blog2|blog3|blog4)(/.*)?$ $1.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php
</IfModule>
Then you can access your blog by typing
blog1 - "http://www.blog.com/blog1/"
category - "http://www.blog.com/blog1/category/"