Advertisement
Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Moderator: General Support Moderators
-
- Joomla! Enthusiast
- Posts: 166
- Joined: Fri Sep 16, 2005 9:59 am
Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
If like me you use 1and1 hosting for a lot of your Joomla sites and are cheesed off with the utterly infuriating lack of 1and1 support on making your sites SEO/SEF and the site borks when you attempt to use the usual .htaccess file with Joomla.
Then you might find it quite hard to sort out.
The problem is one of poor configureation from 1and 1 and is well documented around the forums. The infuriating thing is that no one fix has previously resolved this issue. Until now...
If your site is uploaded and installed in your root directory you will find some forum posts about how to resolve this but to recap you need to change the code in .htaccess from
# RewriteBase /
To
RewriteBase /
Which is all well and good but what if it’s nested inside of a series of folders for whatever reason you have chosen to place it there then what?
Well the standard .htaccess will probably allow you to have SEO but not your sites CSS, which of course renders this useless in production environments. This needs to be stressed this isn’t the fault of Joomla it’s the fault of the server setup at 1and1.
So how do you overcome the problem?
Well it’s a bit of a bodge, perhaps someone in the core team or admins might want to look at this post and decide if there’s any potential problems with this fix however I don’t think there are any apparent ones as it’s simply redefining the root with in the .htaccess code.
Ok enough waffle Garf what’s the flippin code I hear you ask.
Ok you need to make several changes to the .htaccess none of them are more complicated than changing lines of code. You don’t need to make an changes to your Joomla install so assuming that 1and1 don’t fix this anytime soon (it’s a problem dating back to the first iteration of Joomla so don’t hold your breath) then this will work with all future upgrades, and theoretically it should work even if they do fix the problem.
Ok, Ok the code then.
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.
Then find
# RewriteBase /
Uncomment it so it looks like this
RewriteBase /
Then add your directory structure to the site but not the site directory itself after the trailing slash.
So if your site was in directories /root/directory1/ directory 2/Joomla
Then your RewriteBase / would be
RewriteBase / root/folder1/folder2/
Then find
RewriteRule (.*) /index.php
And change it to (in this example)
RewriteRule (.*) /joomla/index.php
Then upload this to the directory above your Joomla install, in this example /directory2.
DO NOT upload the .htaccess to your Joomla root directory this will not work.
I’ve written a template file which can be altered to you specific directory layout which you will need to change the / Folder_or_directory_name/ in the RewriteBase / section to reflect your own directory structure.
And the RewriteRule (.*) / from RewriteRule (.*) /your_joomla_root_directory/index.php to the name of your Joomla install directory or root.
DO NOT upload this file without making the changes above first it won’t work.
Hope this resolves any remaining problems which user might have when using 1and1 hosting and getting SEO to work.
As with anything like this BACK UP YOUR SITE FULLY BEFORE ATTEMPTING THIS FIX.
Just in case whilst it won't affect any of your files in your Joomla install you should do this as a matter of course.
Then you might find it quite hard to sort out.
The problem is one of poor configureation from 1and 1 and is well documented around the forums. The infuriating thing is that no one fix has previously resolved this issue. Until now...
If your site is uploaded and installed in your root directory you will find some forum posts about how to resolve this but to recap you need to change the code in .htaccess from
# RewriteBase /
To
RewriteBase /
Which is all well and good but what if it’s nested inside of a series of folders for whatever reason you have chosen to place it there then what?
Well the standard .htaccess will probably allow you to have SEO but not your sites CSS, which of course renders this useless in production environments. This needs to be stressed this isn’t the fault of Joomla it’s the fault of the server setup at 1and1.
So how do you overcome the problem?
Well it’s a bit of a bodge, perhaps someone in the core team or admins might want to look at this post and decide if there’s any potential problems with this fix however I don’t think there are any apparent ones as it’s simply redefining the root with in the .htaccess code.
Ok enough waffle Garf what’s the flippin code I hear you ask.
Ok you need to make several changes to the .htaccess none of them are more complicated than changing lines of code. You don’t need to make an changes to your Joomla install so assuming that 1and1 don’t fix this anytime soon (it’s a problem dating back to the first iteration of Joomla so don’t hold your breath) then this will work with all future upgrades, and theoretically it should work even if they do fix the problem.
Ok, Ok the code then.
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.
Then find
# RewriteBase /
Uncomment it so it looks like this
RewriteBase /
Then add your directory structure to the site but not the site directory itself after the trailing slash.
So if your site was in directories /root/directory1/ directory 2/Joomla
Then your RewriteBase / would be
RewriteBase / root/folder1/folder2/
Then find
RewriteRule (.*) /index.php
And change it to (in this example)
RewriteRule (.*) /joomla/index.php
Then upload this to the directory above your Joomla install, in this example /directory2.
DO NOT upload the .htaccess to your Joomla root directory this will not work.
I’ve written a template file which can be altered to you specific directory layout which you will need to change the / Folder_or_directory_name/ in the RewriteBase / section to reflect your own directory structure.
And the RewriteRule (.*) / from RewriteRule (.*) /your_joomla_root_directory/index.php to the name of your Joomla install directory or root.
DO NOT upload this file without making the changes above first it won’t work.
Hope this resolves any remaining problems which user might have when using 1and1 hosting and getting SEO to work.
As with anything like this BACK UP YOUR SITE FULLY BEFORE ATTEMPTING THIS FIX.
Just in case whilst it won't affect any of your files in your Joomla install you should do this as a matter of course.
You do not have the required permissions to view the files attached to this post.
Advertisement
-
- Joomla! Fledgling
- Posts: 1
- Joined: Mon Aug 11, 2008 8:14 pm
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
I used the same .htaccess on my 1and1 host and it gave me 'Error 500 - Internal server error' when I clicked on any of the menu items. What am I missing?
You do not have the required permissions to view the files attached to this post.
-
- Joomla! Enthusiast
- Posts: 166
- Joined: Fri Sep 16, 2005 9:59 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
RewriteBase /sangeeth
is you base url (or technically URI)
but you've then put
RewriteRule (.*) /sangeeth/index.php
which would mean the path on your server would be
/sangeeth/sangeeth/index.php
unless that's your file structure then you need to amend to
RewriteRule (.*) /index.php
which is the standard.
you only need to amend the index.php if it's down more than one level after your directory.
is you base url (or technically URI)
but you've then put
RewriteRule (.*) /sangeeth/index.php
which would mean the path on your server would be
/sangeeth/sangeeth/index.php
unless that's your file structure then you need to amend to
RewriteRule (.*) /index.php
which is the standard.
you only need to amend the index.php if it's down more than one level after your directory.
-
- Joomla! Apprentice
- Posts: 37
- Joined: Mon Nov 06, 2006 2:43 pm
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
This change cured my 500 error problem! I would love to understand the technical background!
But I'm getting now in the backend this message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, blabla .com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log
Thank you very much
Martin
But I'm getting now in the backend this message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, blabla .com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log
Thank you very much
Martin
-
- Joomla! Enthusiast
- Posts: 166
- Joined: Fri Sep 16, 2005 9:59 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
that's still a 500 error.
hmm did you add the php 5 script at the top of your htaccess?
hmm did you add the php 5 script at the top of your htaccess?
-
- Joomla! Apprentice
- Posts: 35
- Joined: Sat Mar 08, 2008 11:05 pm
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
I just found this post after I already posted an issue here: http://forum.joomla.org/viewtopic.php?f ... 1#p1443001
any input would be appreciated!
any input would be appreciated!
- Rodesh
- Joomla! Intern
- Posts: 76
- Joined: Wed May 16, 2007 4:45 am
- Location: Omaha
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Just tried this fix and didnt work. But I have to put this in my root and I have other joomla sites. What should I do?
My web design and SEO blog http://www.abcomputered.com or my G+ page https://plus.google.com/+Abcomputeredwebdesign/posts
- ghanlon
- Joomla! Enthusiast
- Posts: 246
- Joined: Tue Oct 02, 2007 2:39 am
- Location: Florida
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
I have found for me, that if I put the htaccess file in the root directory, which is used as my base. I then have mutilple other folders which contain a joomla site. So I have multiple jomla sites in different folders. I only use ONE htaccess file and it is in the ROOT of the server.
btw- I am hosting at godaddy.
Joomla - 1.5.7
hope this may help someone.
btw- I am hosting at godaddy.
Joomla - 1.5.7
hope this may help someone.
- Rodesh
- Joomla! Intern
- Posts: 76
- Joined: Wed May 16, 2007 4:45 am
- Location: Omaha
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
The only problem with that is I have several non-joomla sites and it makes those act nutty...
My web design and SEO blog http://www.abcomputered.com or my G+ page https://plus.google.com/+Abcomputeredwebdesign/posts
- Rowby
- Joomla! Enthusiast
- Posts: 193
- Joined: Sun Dec 11, 2005 9:13 pm
- Location: California
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
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 ------------------------
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 ------------------------
-
- Joomla! Apprentice
- Posts: 8
- Joined: Tue Oct 16, 2007 11:05 am
OK if you find any of the above dont work then try this
Hi If you find any of the above done work with 1and1 then try this. It took me days to figure this out so will surely save you lots of time. 1and1 are fine apart from this annoyance.
I didnt even have to change this when i moved the site into a subfolder. Originally my address was www.mysite.com then moved it to www.mysite.com/newsite and didnt change the rewrite base. It still worked, dont know why.
Now i have the site in a sub directory from the main root like this htdocs/newsite/ and the domain name simply pointing towards the new folder so the actual web address is just www.mysite.com. The following htaccess file works with all these different settings.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start copying below this line
AddType x-mapp-php5 .php
## Can be commented out if causes errors, see notes above.
Options FollowSymLinks
RewriteEngine On
# Uncomment following line if your webserver’s URL
# is not directly related to physical file paths.
# Update Your Joomla/MamboDirectory (just / for root)
# Uncomment this line
RewriteBase /
#comment all of the lines of the below section
########## Begin Standard SEF Section
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
##RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
#RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
#RewriteRule ^(content/|component/) index.php
########## End Standard SEF Section
# Uncomment all lines
########## Begin 3rd Party or Core SEF Section
RewriteCond %{REQUEST_URI} ^(/vietnam/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 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
>>>>>>>>>>>>>>>>>>>>>>>> stop copying
If you find this doesnt work then please let me know. Send me an IM
Personally i like to use sh404sef and have done for years it works great. You need to enable sef in joomla global, enable .htaccess rewrite, install and enable sh404sef, and enable .htaccess rewrite in that extension too. Should have no probs.
By the way a little tip. If you are installing a test site, use a subdomain and point it to your new directory rather than doing the www.mysite.com/newfolder routine which can cause problems when transfering. I learned the hard way and always back up your site !!!!!! Youve been warned.
Regards
Darren
I didnt even have to change this when i moved the site into a subfolder. Originally my address was www.mysite.com then moved it to www.mysite.com/newsite and didnt change the rewrite base. It still worked, dont know why.
Now i have the site in a sub directory from the main root like this htdocs/newsite/ and the domain name simply pointing towards the new folder so the actual web address is just www.mysite.com. The following htaccess file works with all these different settings.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start copying below this line
AddType x-mapp-php5 .php
## Can be commented out if causes errors, see notes above.
Options FollowSymLinks
RewriteEngine On
# Uncomment following line if your webserver’s URL
# is not directly related to physical file paths.
# Update Your Joomla/MamboDirectory (just / for root)
# Uncomment this line
RewriteBase /
#comment all of the lines of the below section
########## Begin Standard SEF Section
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
##RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
#RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
#RewriteRule ^(content/|component/) index.php
########## End Standard SEF Section
# Uncomment all lines
########## Begin 3rd Party or Core SEF Section
RewriteCond %{REQUEST_URI} ^(/vietnam/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 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
>>>>>>>>>>>>>>>>>>>>>>>> stop copying
If you find this doesnt work then please let me know. Send me an IM
Personally i like to use sh404sef and have done for years it works great. You need to enable sef in joomla global, enable .htaccess rewrite, install and enable sh404sef, and enable .htaccess rewrite in that extension too. Should have no probs.
By the way a little tip. If you are installing a test site, use a subdomain and point it to your new directory rather than doing the www.mysite.com/newfolder routine which can cause problems when transfering. I learned the hard way and always back up your site !!!!!! Youve been warned.
Regards
Darren
- astrobot
- Joomla! Apprentice
- Posts: 34
- Joined: Mon Oct 06, 2008 3:45 pm
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Oh my god! this thread has been a life and timesaver!
quickly what i did:
-"# RewriteBase /" To "RewriteBase /" in the .htaccess
-enabled seo settings "Search Engine Friendly URLs" and "Use Apache mod_rewrite"
-then in sh404SEF enabled the component and "with .htaccess" in the advanced tab
and voila!
I'm still clicking on every link just to make sure im not dreaming and getting a 404/500 error or that my css is missing... i cant believe it, its working!
i opened a thread earlier about the problems i had and my configuration here:
http://forum.joomla.org/viewtopic.php?f=544&t=350268
one thing i have to mention though, i had to work with sh404SEF in order to make every page get the right look, cause with joomla's basic seo settings i had some problems with showing modules.. i even got a 404 with an artforms menu item...
I'm working with the german version of 1and1 (1und1), if that changes anything...
thanks again to everybody for the info!
quickly what i did:
-"# RewriteBase /" To "RewriteBase /" in the .htaccess
-enabled seo settings "Search Engine Friendly URLs" and "Use Apache mod_rewrite"
-then in sh404SEF enabled the component and "with .htaccess" in the advanced tab
and voila!
I'm still clicking on every link just to make sure im not dreaming and getting a 404/500 error or that my css is missing... i cant believe it, its working!
i opened a thread earlier about the problems i had and my configuration here:
http://forum.joomla.org/viewtopic.php?f=544&t=350268
one thing i have to mention though, i had to work with sh404SEF in order to make every page get the right look, cause with joomla's basic seo settings i had some problems with showing modules.. i even got a 404 with an artforms menu item...
I'm working with the german version of 1and1 (1und1), if that changes anything...
thanks again to everybody for the info!
-
- Joomla! Fledgling
- Posts: 1
- Joined: Fri Jun 27, 2008 9:18 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Many thanks to all who contributed to this thread, was pulling my hair out untill I found this post.
-
- Joomla! Apprentice
- Posts: 7
- Joined: Tue Feb 05, 2008 8:26 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
I have another kind of problem. I use two Joomla sites. One in the root directory and another one in a sub directory. Everything is hosted on 1and1 and each Joomla site has his own Sql database. I've created my .htaccess file as described in this topic and everything's ok.
But i don't know how to do for the sub directory. I've tried to put the same .htaccess in this sub dir but without succes.
An .htaccess in each directory or only one in the root but with which lines of commands ?
any suggestions ?
thanks
But i don't know how to do for the sub directory. I've tried to put the same .htaccess in this sub dir but without succes.
An .htaccess in each directory or only one in the root but with which lines of commands ?
any suggestions ?
thanks
-
- Joomla! Apprentice
- Posts: 8
- Joined: Tue Oct 16, 2007 11:05 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
You will probably need to put your .htaccess in the sub-folder exactly the same but with the rewrite base as follows
RewriteBase /yoursubfolder
RewriteBase /yoursubfolder
-
- Joomla! Apprentice
- Posts: 7
- Joined: Tue Feb 05, 2008 8:26 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
I've tried but not works ...dprice80 wrote:You will probably need to put your .htaccess in the sub-folder exactly the same but with the rewrite base as follows
RewriteBase /yoursubfolder
-
- Joomla! Apprentice
- Posts: 8
- Joined: Tue Oct 16, 2007 11:05 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Go into your sites configuration file (in the folder that your site is located) and look for the option to change the site path, then go through your site and look for any options to change this in the SEF url module etc. You have to change this everywhere.
Before you do this, go back and read my original post. I did say it was easier to use a subdomain and point it to the subfolder rather than trying to install into a subfolder. This is especially true if you plan to move the site to its own domain at a later date without a sub folder, all your links in the site's pages would need to be changed and you just end up with tonnes of 404 errors.
I have made this mistake myself so just giving you a heads up.
Darren
Before you do this, go back and read my original post. I did say it was easier to use a subdomain and point it to the subfolder rather than trying to install into a subfolder. This is especially true if you plan to move the site to its own domain at a later date without a sub folder, all your links in the site's pages would need to be changed and you just end up with tonnes of 404 errors.
I have made this mistake myself so just giving you a heads up.
Darren
-
- Joomla! Fledgling
- Posts: 1
- Joined: Mon Jan 12, 2009 5:43 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Thank you soooooooooooooooooooooo much,Rowby it works with my joomla 1.5.8 1and1 host.
-
- Joomla! Enthusiast
- Posts: 166
- Joined: Fri Sep 16, 2005 9:59 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
erm be way more specific what isn't working what's your file structure...Rodesh wrote:Just tried this fix and didnt work. But I have to put this in my root and I have other joomla sites. What should I do?
I'm afriad without some more infor then you might as well say why is the internet? innit.
help me to help you.
- ggmittal
- Joomla! Apprentice
- Posts: 32
- Joined: Sat Aug 16, 2008 4:44 am
- Location: Punjab, INDIA
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
John peterr wrote:Hi,
yes this is a greatway. now a days everyone using htaccess and i really want to know more information regarding the htaccess.
according to my knowledge .htaccess is used to manage the urls.. we can also redirect the urls with the help of .htaccess...//
Gaurav Mittal
http://www.till2day.com - Technology Tips and Tricks
http://baydark.com - Black Search Engine
http://www.till2day.com - Technology Tips and Tricks
http://baydark.com - Black Search Engine
- zuzushii
- Joomla! Apprentice
- Posts: 33
- Joined: Fri Feb 06, 2009 2:22 pm
- Location: Paris, France
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Let me just say that this is the first and it is the last time I'm using 1and1.
Oddly, things work when I don't have a htaccess.txt file (even though htaccess.txt means it is "turned off"...even the presence of a mere htaccess.txt screws my site around (major problem: CSS disappears)....
you can take a look at my site test.carolinebouyer.fr
It is in a subfolder on 1and1 called "test"
The only thing screwy is that my "read more" (/lire plus in French) and my Latest News (/posts recents) links do not work...does this have something to do with the htaccess?
Are there any key extensions that I should have? Of course, I tried using sh404SEF because i've heard so much about it (in my newbie fashion) and of course, it stripped my css / my galleries to the bones.
Any thoughts? PM me developer friends.
Oddly, things work when I don't have a htaccess.txt file (even though htaccess.txt means it is "turned off"...even the presence of a mere htaccess.txt screws my site around (major problem: CSS disappears)....
you can take a look at my site test.carolinebouyer.fr
It is in a subfolder on 1and1 called "test"
The only thing screwy is that my "read more" (/lire plus in French) and my Latest News (/posts recents) links do not work...does this have something to do with the htaccess?
Are there any key extensions that I should have? Of course, I tried using sh404SEF because i've heard so much about it (in my newbie fashion) and of course, it stripped my css / my galleries to the bones.
Any thoughts? PM me developer friends.
"A mountain is composed of tiny grains of earth. The ocean is made up of tiny drops of water..."
- Pylon
- Joomla! Enthusiast
- Posts: 150
- Joined: Tue Aug 28, 2007 3:29 pm
- Location: London, UK
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Can I just add my personal experience of .htaccess & SEF with 1&1 in the UK.
I've got it working on all my Joomla sites, but always forget how to do it and keep coming back to this thread!
Also something I've noticed is that if you create a subdomain for the testing/development Joomla site (e.g. dev.mysite.com) and point this subdomain at a folder (with the same name) within the root (e.g. root/dev) your .htaccess file obviously needs to be in the subfolder (dev) but the rewrite base rule does not need to point to that folder, just the root. This conflicts with some of the threads above, but I've found it was the root of the problem with repeated 500 errors, even after implementing everything suggested above.
So if you have a subdomain pointing at a subfolder containing your Joomla instance, the rewrite rule can be as follows...
Try it...
I've got it working on all my Joomla sites, but always forget how to do it and keep coming back to this thread!
Also something I've noticed is that if you create a subdomain for the testing/development Joomla site (e.g. dev.mysite.com) and point this subdomain at a folder (with the same name) within the root (e.g. root/dev) your .htaccess file obviously needs to be in the subfolder (dev) but the rewrite base rule does not need to point to that folder, just the root. This conflicts with some of the threads above, but I've found it was the root of the problem with repeated 500 errors, even after implementing everything suggested above.
So if you have a subdomain pointing at a subfolder containing your Joomla instance, the rewrite rule can be as follows...
Code: Select all
RewriteBase /
http://www.pylondesign.co.uk We don't design Pylons...
http://www.villasanraffaello.com Big Villa for holiday rental in Le Marche, Italy
http://www.villasanraffaello.com Big Villa for holiday rental in Le Marche, Italy
- zuzushii
- Joomla! Apprentice
- Posts: 33
- Joined: Fri Feb 06, 2009 2:22 pm
- Location: Paris, France
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Would an .htaccess doc that I found in the drupal forums work for joomla?
i still cannot figure out my rewrite base....do I have to put "root" somewhere? I have everything in a folder, like http://www.mysite.com/folder
would my base simply be "/folder?"
Thanks,
Sarah
i still cannot figure out my rewrite base....do I have to put "root" somewhere? I have everything in a folder, like http://www.mysite.com/folder
would my base simply be "/folder?"
Thanks,
Sarah
Code: Select all
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.
# PHP 4, Apache 1.
<IfModule mod_php4.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
</IfModule>
# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
</IfModule>
# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
</IfModule>
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
# Do not cache dynamically generated pages.
ExpiresByType text/html A1
</IfModule>
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# If your site can be accessed both with and without the prefix www. you
# can use one of the following settings to force user to use only one option:
#
# If you want the site to be accessed WITH the www. only, adapt and
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule .* http://www.example.com/ [L,R=301]
#
# If you want the site to be accessed only WITHOUT the www. prefix, adapt
# and uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule .* http://example.com/ [L,R=301]
# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
RewriteBase /
# Rewrite old-style URLs of the form 'node.php?id=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^id=([^&]+)$
#RewriteRule node.php index.php?q=node/view/%1 [L]
# Rewrite old-style URLs of the form 'module.php?mod=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
#RewriteRule module.php index.php?q=%1 [L]
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]
</IfModule>
# $Id: .htaccess,v 1.81 2007/01/09 09:27:10 dries Exp $
- Pylon
- Joomla! Enthusiast
- Posts: 150
- Joined: Tue Aug 28, 2007 3:29 pm
- Location: London, UK
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Following your PM...
"root" is often used to refer to the highest level directory/folder of your domain within which everything else is contained. So the "root" of your domain is http://www.mysite.com/
http://www.mysite.com/folder is therefore a directory/folder contained within your "root".
I wouldn't use something from Drupal (although I could be wrong!). Each core Joomla installation has an htaccess file included, but it is initially called htacces.txt - once it's up on your server you need to rename it .htaccess using your ftp software.
This will make it 'an invisible file' on many operating systems/servers, so ensure your ftp software allows you to view "hidden/invisible files". You can then see it and edit it when required.
If your Joomla installation is contained within a folder called "folder' directly within the "root", your ReWrite Base would indeed be (once it has been uncommented)...
However, as I mention above, I've found that it can also work as...
even if the Joomla instance is within a sub-folder such as yours is - try both.
I've attached the htacces.txt file that comes with Joomla 1.5.9 by default.
If you're on 1&1 too, you will also want to add the following lines of code somewhere in the .htaccess file (position is not critical) to ensure the Joomla install can make use of PHP5, rather than the default PHP4.
Hope that explains things a bit clearer.
NO.do I have to put "root" somewhere?
"root" is often used to refer to the highest level directory/folder of your domain within which everything else is contained. So the "root" of your domain is http://www.mysite.com/
http://www.mysite.com/folder is therefore a directory/folder contained within your "root".
I wouldn't use something from Drupal (although I could be wrong!). Each core Joomla installation has an htaccess file included, but it is initially called htacces.txt - once it's up on your server you need to rename it .htaccess using your ftp software.
This will make it 'an invisible file' on many operating systems/servers, so ensure your ftp software allows you to view "hidden/invisible files". You can then see it and edit it when required.
If your Joomla installation is contained within a folder called "folder' directly within the "root", your ReWrite Base would indeed be (once it has been uncommented)...
Code: Select all
RewriteBase /folder
Code: Select all
RewriteBase /
I've attached the htacces.txt file that comes with Joomla 1.5.9 by default.
If you're on 1&1 too, you will also want to add the following lines of code somewhere in the .htaccess file (position is not critical) to ensure the Joomla install can make use of PHP5, rather than the default PHP4.
Code: Select all
###### Begin parse php4 files as php5
AddType x-mapp-php5 .php
###### End parse php4 files as php5
You do not have the required permissions to view the files attached to this post.
http://www.pylondesign.co.uk We don't design Pylons...
http://www.villasanraffaello.com Big Villa for holiday rental in Le Marche, Italy
http://www.villasanraffaello.com Big Villa for holiday rental in Le Marche, Italy
- gholem
- Joomla! Apprentice
- Posts: 14
- Joined: Tue Jan 13, 2009 7:34 am
- Location: Uk
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Hello all,
I have this question - might sound stupid - i gotta ask:
How can I "teak" .htaccess to make my links appear like this:
instead of looking like this:
I understand there are some issues with myblog component, but leaving this for a moment, if I have a link like this one : how can I SEF it like
Thank you very much for any feedback and help!
I have this question - might sound stupid - i gotta ask:
How can I "teak" .htaccess to make my links appear like this:
Code: Select all
[b]www.mydomain.com/top-7/muzici-din-filme.html[/b]
Code: Select all
[b]www.mydomain.com/component/content/article/22-top-7-muzica-nu-ucide/87-muzici-din-filme.html[/b]
I understand there are some issues with myblog component, but leaving this for a moment, if I have a link like this one :
Code: Select all
[b]www.mydomain.com/component/content/article/34-rochii/47-rochie-speciala.html[/b]
?
Thank you very much for any feedback and help!
-
- Joomla! Enthusiast
- Posts: 166
- Joined: Fri Sep 16, 2005 9:59 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
That's worth starting a new thread about really...gholem wrote:Hello all,
I have this question - might sound stupid - i gotta ask:
How can I "teak" .htaccess to make my links appear like this:
instead of looking like this:Code: Select all
[b]www.mydomain.com/top-7/muzici-din-filme.html[/b]
Code: Select all
[b]www.mydomain.com/component/content/article/22-top-7-muzica-nu-ucide/87-muzici-din-filme.html[/b]
I understand there are some issues with myblog component, but leaving this for a moment, if I have a link like this one :how can I SEF it likeCode: Select all
[b]www.mydomain.com/component/content/article/34-rochii/47-rochie-speciala.html[/b]
?
Thank you very much for any feedback and help!
The answer is with the default SEF then you can't.
What's happening in those SEF links is that it's picking up the unquie id of the section or content item or catigory inorder to ensure that the links are unique.
To change this behaviour you'd need to rewrite the SEF in the core J! app, or use an alternative SEF component which allows SEF editing ad-hoc via the back end.
- gholem
- Joomla! Apprentice
- Posts: 14
- Joined: Tue Jan 13, 2009 7:34 am
- Location: Uk
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Thank you for the answer. Didn't know it's so difficult.GarfieldLeChat wrote:
That's worth starting a new thread about really...
The answer is with the default SEF then you can't.
What's happening in those SEF links is that it's picking up the unquie id of the section or content item or catigory inorder to ensure that the links are unique.
To change this behaviour you'd need to rewrite the SEF in the core J! app, or use an alternative SEF component which allows SEF editing ad-hoc via the back end.
But if I use a SEF component for editing the links in the backend it's not quite the same thing, the pages won't load that fast, indexing it's not the same, usually there are bugs and security breaches, there will always be another update for J! and some component's updates behind, or, I don't know, stuff...
I'm just saying, don't know much about Apache and php.
I would start a new thread about this but I need some back-up, someone who knows what I try to say and where I'm heading.
-
- Joomla! Enthusiast
- Posts: 166
- Joined: Fri Sep 16, 2005 9:59 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
I my experience of these forums theres' considerable help which flows through these waters someone will get what you are saying and help you work through it.gholem wrote:Thank you for the answer. Didn't know it's so difficult.GarfieldLeChat wrote:
That's worth starting a new thread about really...
The answer is with the default SEF then you can't.
What's happening in those SEF links is that it's picking up the unquie id of the section or content item or catigory inorder to ensure that the links are unique.
To change this behaviour you'd need to rewrite the SEF in the core J! app, or use an alternative SEF component which allows SEF editing ad-hoc via the back end.
But if I use a SEF component for editing the links in the backend it's not quite the same thing, the pages won't load that fast, indexing it's not the same, usually there are bugs and security breaches, there will always be another update for J! and some component's updates behind, or, I don't know, stuff...
I'm just saying, don't know much about Apache and php.
I would start a new thread about this but I need some back-up, someone who knows what I try to say and where I'm heading.
on j! 1.0 series there was an issue of updates killing things dead and unworked projects not being updated however since .15 series there has been pretty much a metronoic release of new J! updates and detailed information about what is being changed.
however the core team cannot and shouldn't be expected to know about eveyr tiny single piece of programming which has every happen for J! there's a shedload still born projects which have cluttered up the past.
Well designed components which follow J!'s really clear API will be unlikely to break unless there's a minor code error (as has happened recently in the 11 to 12 update which took all of 30 sec's to search for and fix thus repairing it again).
If you compoent is relying on working on broken code then yes it's a security risk.
A well set up site with Cached SEF will be as fast if not faster than loading a standard site. Optimiseation doesn't just happen on sites you know
But really post what you've posted here on another thread not being all teritorial about this thread it's just you'll not get the help you need or want tagging things on to a thread nearly a year old...
- gholem
- Joomla! Apprentice
- Posts: 14
- Joined: Tue Jan 13, 2009 7:34 am
- Location: Uk
- Contact:
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
Ok, @GarfieldLeChat. My bad. I guess you're right and I should try that.
I'm going to take a project of mine and put it on the table, but first try some SEF & SEO components, not to waste anybody's time for just "IF's" .
Thanks againg for your answer and I promise to come back with some stuff.
I'm going to take a project of mine and put it on the table, but first try some SEF & SEO components, not to waste anybody's time for just "IF's" .
Thanks againg for your answer and I promise to come back with some stuff.
-
- Joomla! Apprentice
- Posts: 11
- Joined: Thu Sep 03, 2009 1:27 am
Re: Definitive (I think) .htaccess SEO/SEF 1and1 hosting fix
This problem was really driving me nuts. I followed the instructions exactly, but one odd thing kept them from working initially. I'll point it out here in case anyone else runs into it.
I edited .htaccess by right-clicking the file within FileZilla on the remote server and picking "View/Edit". My text editor, Notepadd++, opened the file locally and I made the changes. I saved. FileZilla asked me if I wanted to propogate the changes to the server version of .htaccess. I said Yes. For some reason, this caused ".htaccess" to change to "htaccess" (no dot)! It took me an hour to figure out why none of the settings were taking affect.
Also, I did change htaccess to 755 permissions at the same time that I changed the file name. Last bit is probably not relevant.
I edited .htaccess by right-clicking the file within FileZilla on the remote server and picking "View/Edit". My text editor, Notepadd++, opened the file locally and I made the changes. I saved. FileZilla asked me if I wanted to propogate the changes to the server version of .htaccess. I said Yes. For some reason, this caused ".htaccess" to change to "htaccess" (no dot)! It took me an hour to figure out why none of the settings were taking affect.
Also, I did change htaccess to 755 permissions at the same time that I changed the file name. Last bit is probably not relevant.
Advertisement