Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix

Discuss Search Engine Optimization in relation to Joomla!. This forum will also have discussions on SEF/SEO Joomla! extensions.

Moderator: General Support Moderators

kivnic
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Sep 03, 2009 1:27 am

Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix

Post by kivnic » Thu Oct 08, 2009 2:08 am

Ahhh I spoke to soon :(

When I enabled mod_rewrite in the Joomla Global Configure screen I'm still having problems. I'll describe what I've done and why, and hopefully someone can tell me where I'm going wrong.

1) Developed my Joomla site using ApacheFriends XAMPP (Basispaket) version 1.7.1, and Joomla! 1.5.14
2) Exported my MySQL database, then imported it to a MySQL database on my 1and1 server that already had some sample Joomla data in it.
3) Edited my local configuration.php file to reflect 1and1.com settings and sever database.
4) Deleted the test site on the 1and1.com server.
5) Uploaded my local dev site to the server.
6) Uploaded site works with SEF enabled, but fails once I enabled "Use mod_rewrite". It's a new error this time - "Error 500 - Internal server error"
7) There's another problem that might be related. After moving the build to my 1and1 server, several variables are displaying variable names instead of values.
- instead of seeing dates I see "DATE_FORMAT_LC2".
- On the Admin login page I see "DESCUSEVALIDLOGIN".
- If I log on with a bad password, I see "E_LOGIN_AUTHENTICATE
* My site is located in /MySiteName/htdocs.
- I placed .htaccess at /MySiteName/ with 755 permissions.
* .htaccess is attached
You do not have the required permissions to view the files attached to this post.

GarfieldLeChat
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 166
Joined: Fri Sep 16, 2005 9:59 am

Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix

Post by GarfieldLeChat » Thu Oct 08, 2009 8:43 am

as mentioned in my first post

Firstly make sure that you running php 5 not php 4 I haven’t tested this with php 4 though again it should work.
In your .htaccess find

## Can be commented out if causes errors, see notes above.

And add above it

AddType x-mapp-php5 .php

So it looks like this

AddType x-mapp-php5 .php
## Can be commented out if causes errors, see notes above.
500 errors are likely caused by not running in php 5 as the server one 1 & 1 times out.

kivnic
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Sep 03, 2009 1:27 am

Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix

Post by kivnic » Thu Oct 08, 2009 7:54 pm

Hi GarfieldLeChat,

I've moved "AddType x-mapp-php5 .php" to the absolute first line in the .htaccess file. It hasn't helped unfortunately. However, I'm pretty sure that it's being seen and the PHP5 is being used. Inside the Admin tool, when I got to Help-->System Info, Joomla! reports:

PHP Built On: Linux infong 2.4 #1 SMP Thu May 28 16:09:02 UTC 2009 i686 GNU/Linux
Database Version: 5.0.81-log
Database Collation: utf8_general_ci
PHP Version: 5.2.11
Web Server: Apache
WebServer to PHP Interface: cgi
Joomla! Version: Joomla! 1.5.14 Stable [ Wojmamni Ama Naiki ] 30-July-2009 23:00 GMT
User Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.3) Gecko/20090824 (CK-IBM) Firefox/3.5.3

User avatar
GreatGatsby
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 234
Joined: Tue Oct 02, 2007 2:03 pm
Location: Michigan
Contact:

Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix

Post by GreatGatsby » Fri Oct 09, 2009 8:14 pm

I'm also using 1&1 hosting. I have a site where if I enable just the "Search Engine Friendly URLs" in Global Configuration, all my site's pages work fine, but they have the /index.php on all of them.

If I also enable "Use Apache mod_rewrite", I get 404 errors on all pages but the home page.

I do not have any SSL or secure pages.

I would like to enable the mod_rewrite so that I don't have the /index.php in all my URLs, but it doesn't work with my current configuration. Any help?

Current .htaccess file:

Code: Select all

##
# @version $Id: htaccess.txt 9975 2008-01-30 17:02:11Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##


#####################################################
#  READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations.  It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file.  If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's.  If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

AddType x-mapp-php5 .php
##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On


#  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


########## 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 <script> 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

System Info:

Code: Select all

PHP Built on:   	 Linux infong 2.4 #1 SMP Thu May 28 16:09:02 UTC 2009 i686 GNU/Linux
Database Version: 	5.0.81-log
Database Collation: 	utf8_general_ci
PHP Version: 	5.2.11
Web Server: 	Apache
Web Server to PHP interface: 	cgi
Joomla! Version: 	Joomla! 1.5.14 Stable [ Wojmamni Ama Naiki ] 30-July-2009 23:00 GMT
User Agent: 	Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14 (.NET CLR 3.5.30729) 
Jason Boyette

spadam
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Feb 24, 2011 11:03 pm

Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix

Post by spadam » Mon May 30, 2011 1:13 am

Just wanted to add my thanks to all who have offered advice above. After the best part of a day wrestling with the 1&1 environment I now have a Joomla 1.6 site working with SEF urls enabled, and have learnt plenty in the process. :)

User avatar
razor7
Joomla! Explorer
Joomla! Explorer
Posts: 374
Joined: Wed Aug 24, 2005 2:06 pm
Location: Argentina
Contact:

Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix

Post by razor7 » Thu Oct 18, 2012 1:11 am

Rowby wrote:Folks, are you on 1and1 and are following this thread?? Did you waste a half a day trying to figure out what the heck was going on with your site?????? Well thanks to this thread I finally got sh404SEF to work on 1and1.

This thread fixed it for me, but I figured I would put together a post to sum it all up and get it working for you 1and1 Joomla sites.

First of all, I never use 1and1 for Joomla hosting anymore. 1) They don't let you see error logs. Also they don't use Cpanel which is much easier and more full featured than their own control panel. And they have this subdirectory thing where you have to assign domains to different subdirectories, which causes all kinds of grief. I personally use Hostgator and am very happy with them.

But for this one client I am stuck at 1and1. And I ran into the same problem with 501 errors once I turned on SEF. As it turned out, by following this thread I realized that this domain was in one of the subdirectories in the client's hosting plan. Also the hosting was set for PHP 4. The following is the complete fix to resolve the problems I had. No more 501 errors for this domain that was in the subdirectory.

Before you use my "fix" make sure you copy your existing htaccess file to notepad, in case something goes wrong.

The below is not my original work -- but it's what I pieced together after reading this thread:

---------------------------- start copying BELOW this line --------------------------

## One and One PHP5 setting
AddType x-mapp-php5 .php
## END - One and One PHP 5 Settings

##
# @version $Id: htaccess.txt 10492 2008-07-02 06:38:28Z ircmaxell $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##


#####################################################
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
# mod_rewrite in use

RewriteEngine On

########## 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 <script> 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

# 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


--------------- STOP COPYING BEFORE THIS LINE ------------------------
Great it worked!

Thanks!
Visit http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more! http://www.mgscreativa.com/contenidos/i ... Itemid=214


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 1.5”