Welcome to WebmasterWorld Guest from 54.198.222.129

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Preventing conflicts with WP mod_rewrite code

and speeding it up as well

     
8:53 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Senior Member wheel is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I've got wordpress installed in my root folder, and some other unrelated stuff in my /cgi-bin.

When I install the wordpress permalinks htaccess in my root, stuff in my cgi-bin directory gets an access denied error message:

here's my wordpress htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

And here's what's in the <directory> block for my cgi-bin in my httpd conf file:
AllowOverride All
Options None ExecCGI
DirectoryIndex index.html
AddHandler cgi-script .cgi .pl
Order allow,deny
Allow from all

Any thoughts on what's causing my cgi-bin programs to get access denied? Or how to opt out my cgi-bin directory from the root .htaccess directives?

2:50 am on Sep 26, 2010 (gmt 0)



Jim:

You made a comment about making a similar modification to the htaccess file of a Joomla site. Here is a portion of my htaccess file. Would you be willing to indicate the changes necessary for me as well?

# mod_rewrite in use

RewriteEngine On

RewriteCond %{HTTP_HOST} ^ourfullhouse.com [NC]
RewriteRule ^(.*)$ [ourfullhouse.com...] [L,R=301]

# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)

# RewriteBase /


########## Begin - Joomla! core SEF Section
#
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]
#
########## End - Joomla! core SEF Section

Much appreciated!

Andy
7:14 am on Sep 26, 2010 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



The non-www to www redirect can be improved:

RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


The above will redirect for all non-canonical hostnames, including requests with trailing port numbers, etc.



The Joomla changes are documented and discussed here:
[webmasterworld.com...]
[webmasterworld.com...]
[docs.joomla.org...]

The patch is here:
[joomlacode.org...] [1218 bytes]
7:49 pm on Sep 26, 2010 (gmt 0)



Thanks much for the input on the redirect and also the links!

Grateful,

Andy
8:35 pm on Sep 26, 2010 (gmt 0)



With the patch that you've submitted, how/where does it get applied? Does it make these changes?

########## Begin - Joomla! core SEF Section
#
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]
#
########## End - Joomla! core SEF Section

to...

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]
8:42 pm on Sep 26, 2010 (gmt 0)



As a note, I've applied the above recommended changes to my htaccess file.
9:41 pm on Sep 26, 2010 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



The patch makes the changes listed on the mentioned Joomla
docs:talk
page to the
.htaccess
file.

The
[F,L]
flag becomes just
[F]
and the rest of the code changes to:

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


This alone will give a noticeable speed increase for any site using Joomla.
5:07 pm on Mar 1, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Updated code for Joomla 1.5 and Joomla 1.6 is here: [webmasterworld.com...]
This 37 message thread spans 2 pages: 37
 

Featured Threads

Hot Threads This Week

Hot Threads This Month