The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Mar 10, 2012 12:17 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Mar 08, 2012 10:52 am
Posts: 15
Hi, am currently using the following in my .htaccess file
Code:
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?|php)\ HTTP/
RewriteCond %{REQUEST_URI} !^/administrator
RewriteRule (([^/]+/)*)index\.(html?|php)$ http://www.example.com/$1 [R=301,L]

This rule breaks the core Joomla search, which rubbish though it is, we would rather have functioning! When I say it 'breaks' it, I mean that normally when you enter a search term the url looks like
Code:
 www.example.com/component/search/example?ordering=&searchphrase=all
instead of which it redirects to either the root or the nearest /. I have no idea why it would do this as the search url contains no instance of 'index' . Anybody? ???


edit: been trying to research this and realised I should maybe uncomment
Code:
RewriteBase /
which I did - seemed to make things better, in that the search bar looked like it was trying but redirected to component / search, bringing no results for anything. So have temporarily commented out the rule I want to use. Annoying, because Google hasn't canonicalized the pages, and lists them as two separate pages #(example.com/index.php and example.com both listed.) any help most appreciated!


Last edited by maemae on Sun Mar 11, 2012 12:20 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sat Mar 10, 2012 11:37 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Mar 08, 2012 10:52 am
Posts: 15
think I fixed it..


Top
 Profile  
 
PostPosted: Sun Mar 11, 2012 12:09 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Mar 08, 2012 10:52 am
Posts: 15
ok just in case someone else is having trouble and are getting as crashing a silence as me on the forums... try this modified .htaccess file - works great - redirects index.php to root without locking admin out and without affecting the search module or as far as I know any other search module - and speeds up page load. YEAH :D


Code:
##
# @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

##redirect index urls
########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
########## End - 301 Redirect




########## 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
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for the site root, or for an extensionless URL,
# or the requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw|ini|zip|json|file))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
########## End - Joomla! core SEF Section


Top
 Profile  
 
PostPosted: Sat May 05, 2012 11:57 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat May 05, 2012 11:49 am
Posts: 1
Dude, thankyou so much for posting this. I've been trying to redirect index.php to root for hours without success. The reason being is that I was using:

Code:
#RewriteCond %{REQUEST_URI} !^/administrator
#RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
#RewriteRule ^(.*)index\.php$ /$1 [R=301,L]


But this broke my Jomsocial notifications module as it relies on the index.php.

Your solution not only redirects index.php to root for me but it resolved the jomsocial notifications issue.

The code I took from your example was:

Code:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
   RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.bodybuildpro.com/$1 [R=301,L]
   #
   RewriteCond %{THE_REQUEST} !^POST
   RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
   RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
   RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.bodybuildpro.com/$1 [R=301,L]
   #
   RewriteCond %{HTTP_HOST} !^(www\.bodybuildpro\.com)?$
   RewriteRule (.*) http://www.bodybuildpro.com/$1 [R=301,L]


Would you care to explain a bit more what each line does? I'm not sure if I need it all or not.

Best Regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 



Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group