Talk

Preconfigured .htaccess

From Joomla! Documentation

Revision as of 14:34, 13 September 2010 by G1smd (talk | contribs) (Reply to questions posed here and at www.webmasterworld.com/apache/4200031.htm)

I'm not well versed in htaccess, but like many people, I have set up my Joomla instance in a directory off the root. And like most people, I have had quite a time trying to modify both my configuration.php as well as the htaccess to make the URL appear to go to the domain root and not show the Joomla folder.

I would like to see an htaccess option that is preconfigured for a sub-directory as well...or at least commented code that allows you to easily switch.

Also, I heard the current htaccess is considered very inefficient, although lacking apache skills I could not tell you why. The current file is copyrighted, so I can't post the contents on forums to get help.

So if the copyright can't be lifted (which would be perfectly acceptable) then the only other recommendation is bringing in other resources to review and improve the file.

Just my two cents.

Dlwilson007 17:55, 13 September 2010 (UTC)



The following edits to the .htaccess file are in order.

1. Correction to syntax.

RewriteRule ^(.*)$ index.php [F,L]

F implies, L; remove L.

RewriteRule (.*) index.php [F]

2. Improvements to efficiency.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

The -f and -d "exists" checks are VERY inefficient, requiring the server to make two physical disk reads for EVERY request made of the server. This massively slows the page serving. For a busy site these checks will force an early server upgrade, as well as rapidly beating the hard drive to death. The -f and -d checks should be the LAST ones. The Rewrite also needs an [L] flag added.

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html?|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]

http://www.webmasterworld.com/apache/4073048.htm http://www.webmasterworld.com/apache/4200031.htm and others, refer.

(G1smd 19:34, 13 September 2010 (UTC))