Author Topic: OpenSEF htaccess and Apache Configuration Tips  (Read 10420 times)

0 Members and 2 Guests are viewing this topic.

Offline kenmcd

OpenSEF htaccess and Apache Configuration Tips
« on: 08. November 2007, 03:34:27 »
 
FIRST - Test if mod_rewrite is working
Having problems getting Joomla core SEF to work?
If mod_rewrite is not working, nothing else you do matters.
Test this first.

Test if mod_rewrite is working
Put only these two lines in your .htaccess file.

Code:
Options +FollowSymLinks
Redirect /google.html http://www.google.com


Now point your browser to: http://www.yoursite.com/google.html
If it redirects you to Google - mod_rewrite is working.
If it gives you an error - mod_rewrite is not working.

Note: Replace "www.yoursite.com" with your actual web site domain.

-----

If mod_rewrite is not working, check Apache configuration.

Apache requirements for mod_rewrite to work
The Apache httpd.conf file has the settings to enable URL rewriting.
Two settings are required.
1. mod_rewrite module is installed
Search file for LoadModule rewrite_module and un-comment that line (remove the leading #)
2. AllowOverride All
Search file for AllowOverride None and change it to AllowOverride All
3. Restart Apache
Restarting the Apache web server is required for the changes to take effect.


SECOND - OpenSEF Simplified .htaccess File
After you have confirmed that mod_rewrite is working
Try this as your htaccess file:
Code: [Select]

## OpenSEF Simplified htaccess File

## Can be commented out if causes errors
Options +FollowSymLinks

## enable mod_rewrite engine
RewriteEngine On

## If Joomla is installed in the web server root
## RewriteBase /
## If Joomla is installed in a sub-directory
## RewriteBase /directory_name_here
RewriteBase /

## Begin 3rd-Party or OpenSEF Section
#RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR]  ##optional - see notes##
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php
## End 3rd-Party or OpenSEF Section

## Joomla Security Section (has nothing to do with SEF/SEO)
## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
## End - Rewrite rules to block out some common exploits

This is simply the J 1.0.12 htaccess file with the unneeded comment text removed and the standard Joomla core SEF rewrite section removed. What is left is just the lines of the file actually needed.
 

Note: Also see Using OpenSEF in the Sigsiu.NET SOBI2 FAQ
http://www.sigsiu.net/faq/search_engine_friendly_urls/how_to_use_sobi2_with_opensef.html
 
 
« Last Edit: 17. November 2009, 17:17:45 by aboututila »
50 SOBI2 Joomla Web Sites - Free! Publication Available
A showcase of 50 SOBI2 websites with screenshots and descriptions of add-ons used.
Direct download (22MB): 50-SOBI2-Joomla-Web-Sites.2008-11-10.CHM.zip
Country: United States United States |  OS: Unknown Unknown Browser: Unknown Unknown | View Profile Joomla Docs

Tags: