Documentation

Remove index.php from URL

Improve the look of short URLs by removing index.php from it. For example you can convert short URLs like http://www.xaraya.com/index.php/article to http://www.xaraya.com/article

Scenario

You want URLs easier to read and more search engine friendly.

Removing index.php from the URL can be easely done by using a .htaccess file and by amending the Xaraya config file.

Check the system

This method has been tested in apache webservers with mod_rewrite installed. IIS has url rewriting plugins, but I haven't test them yet.

Create the htaccess file

Create a file called .htaccess in your xaraya root folder and put this text:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) index.php/$1 [L]

Save it, good!

Note: file must be uploaded as ASCII, and have permission 644

Amend config.system.php

Open the file config.system.php stored in /var/ and change the last lines from:

//$systemConfiguration['BaseURI'] = '';
//$systemConfiguration['BaseModURL'] = '';

to:

$systemConfiguration['BaseURI'] = '';
$systemConfiguration['BaseModURL'] = ''
;

If you have installed xaraya in a subfolder like http://localhost/foldername/, change the lines to:

$systemConfiguration['BaseURI'] = '/foldername';
$systemConfiguration['BaseModURL'] = '';

Note: If you followed the security instructions when you installed xaraya, you might have to set (CHMOD) write permission and change the owner (CHOWN) to yourself.

Save it, CHMOD the file to 444 (read only) and change owner (CHOWN).

Should be done!

Notes:
You should also be sure your apache httpd.conf file allows modrewrite overrides in the .htaccess. In your <Directory [webroot] >  section, set "AllowOverride option" or "AllowOverride all"

When you have troubles and don't get the rewrite to work, try adding an extra '/', as has been done below:

 RewriteRule ^(.+) /index.php/$1 [L]

A more advanced .htaccess is given below:
RewriteEngine On
# Here comes your base directory
RewriteBase /yourbasedir/toxaraya/
# Deny access from .htaccess
RewriteRule ^\.htaccess$ - [F]
# Missing favicon should not cause Xaraya to be loaded..
RewriteRule ^favicon\.ico - [L]
# Existing files shouldn't get rewritten
# but the rest can go to Xaraya
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) index.php/$1 [L]

This one will add extra speed, as a missing favicon will not cause Xaraya to load.

Change the last line to the following if you run into a redirect loop (encountered when using multiform pages in the Xarpages module):
RewriteRule ^(.+) index.php/$1 [L,QSA]


Maintainer: Denis Last modified on Sep 14, 2008 4:58:09 AM by krzysz