If you add an 'alias' name for your PHPWCMS categories, mod_rewrite can also change URLs like 'index.php?products' into 'products.phtml'
This explains how I achieved this with:
PHPWCMS 1.2.5
XAMPP 1.4.13
PHP 4.3.11
Windows XP Home
It involves modifying some critical files, so make backups of everything you change.
Step 1) Edit http.conf
To use mod_rewrite with XAMPP, you have to edit xampp/apache/conf/http.conf
1) Check around line 221 the entry:
AddType application/x-httpd-php .php .php3 .phtml
and make sure the .phtml extension is present.
2) Around line 414, check that the entry specifies the .htaccess file:
AccessFilename .htaccess
3) Around line 166, uncomment the Line:
#LoadModule rewrite_module modules/mod_rewrite.so
4) Check the entry around line 362. If it reads:
AllowOverride None
change it to:
AllowOverride All
You need to re-start the Apache server for the effects to take place.
Step 2) Edit the PHPWCMS file conf.inc.php
Edit conf.inc.php and around line 43, change:
$phpwcms["rewrite_url"] = 0; //whether URL should be rewritable
to:
$phpwcms["rewrite_url"] = 1; //whether URL should be rewritable
Step 3) Edit the supplied PHPWCMS file _.htaccess
If PHPWCMS is installed in a sub-directory, you need to edit this file to add the sub-directory (replace the word 'site' with the target directory name). The example below is a slightly modified version designed for an installation in the web root, minus the original file comments.
Code: Select all
php_flag magic_quotes_gpc Off
php_flag register_globals Off
Options +FollowSymlinks
RewriteEngine On
DirectoryIndex index.html index.php
#If PHPWCMS is in the root directory
RewriteRule ^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.phtml$ index.php?id=$1,$2,$3,$4,$5,$6
RewriteRule ^(.+)\.phtml$ index.php?$1
#If PHPWCMS is in a sub-directory
#RewriteBase /site
#RewriteRule ^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.phtml$ /site/index.php?id=$1,$2,$3,$4,$5,$6
#RewriteRule ^(.+)\.phtml$ /site/index.php?$1
You can't simply rename this file in Windows explorer, you have to do it from an application.
Open _.htaccess in any text editor
Select File/Save As
In the 'Save as type' box select 'All Files (*.*)'
In the 'File name' box change file name to .htaccess
Click Save.
Alternatively, you could open a command prompt (dos box) and type:
ren htaccess.txt .htaccess
Step 5) ** IMPORTANT **
If PHPWCMS is installed in a sub-directory, place the .htaccess file in this directory, *NOT* the web root.
After some trial and error, the above process worked for me. Plus, the site I tested this on had been built using IIS, so it's nice to know that changing to Apache + mod_rewrite didn't kill it!
Hope somebody finds this useful.
![Smile :)](./images/smilies/icon_smile.gif)