This is just going to be a small tutorial on how to use an .htaccess file with Pligg and what it can do for your Pligg site.
- There is no support for .htaccess on windows servers e.g. IIS. This has to do with how Windows servers work and is not an issue with Pligg. This tutorial will be biased towards Apache since that's what most people use.
- Make sure that mod_rewrite is enabled in Apache. If you have access to your Apache httpd.conf file search for LoadModule rewrite_module modules/mod_rewrite.so and make sure there isn't a # in front of it. If there is, remove it and save the file. You will need to restart Apache for this to take effect. If you follow this tutorial and get an error that says "Internal Server Error" or something similar that usually means that mod_rewrite is not enabled.
- Next rename your htaccess.default file to .htaccess (Note the period in front of it)
- Now I am going to go through the important things in the .htaccess file that you need to know about
- RewriteBase /
This tells the .htaccess file where your Pligg is installed. If it's installed in the root of your server then you don't need to change this line. If you installed Pligg in a subfolder called pligg then you will want to change it to RewriteBase /pligg - RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^/?(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This section of code will automatically put www. in front of your URL when someone visits your site. Most of the time this will fix the problem people run in to when voting won't work unless www. is used in the URL. This code should be removed if you do no want www. automatically appended to the URL. - RewriteRule ^(all|pligg)/([a-zA-Z0-9-]+)/?$ story.php?title=$2 [L]
RewriteRule ^(all|pligg)/?$ ?category=$1 [L]
You will notice these two lines in your .htaccess file. These are very important once you start adding categories to your Pligg site. Once you are in the category manager you will notice that it automatically produces the code you need for your categories to work with the .htaccess file. You will copy that code over the code above.
The rest of the htaccess file is for the use of URL method 2 or "clean" urls. For example:
www.mydomain.com/search.php?search=technology would change to
www.mydomain.com/search/technology
Pligg beta 9 has quite a few bugs when it comes to using "clean" urls but they have since been fixed and if you would like to have this working on your site here is a quick tutorial on how to get the latest SVN code:
http://www.pligg.com/forum/showpost....92&postcount=2
Here is the article on wikipedia about htaccess
.htaccess - Wikipedia, the free encyclopedia