homepage Welcome to WebmasterWorld Guest from 54.167.41.199
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
301 redirect .htaccess for non-SEF URL of Joomla
301 redirect Joomla
truemaker




msg:4271445
 12:59 pm on Feb 24, 2011 (gmt 0)

Greetings to all.
There is a Joomla site with long links.
Need to do 301 redirect from one page to another on the same domain.
Different ways (mod rewrite strings in htaccess) or lead to the absence of forward or to the 500 error.
Really need your help.
Anybody can help me ?

EXAMPLE
Source URL
[domain.zone2.zone1...]

Destination URL (301 redirect)
[domain.zone2.zone1...]
--------------------------
.HTACCESS source

##
# @version $Id: htaccess.txt 14401 2010-01-26 14:10:00Z louis $
# @package Joomla
# @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
# @license [gnu.org...] 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!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
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

AddDefaultCharset utf-8
php_value default_charset utf-8

---------------------------------------

WBR
truemaker

 

g1smd




msg:4271479
 2:29 pm on Feb 24, 2011 (gmt 0)

First of all, update your .htaccess file to the new version at: [joomlacode.org...]

Any questions? Ask here. I wrote that patch.

Next, add this new code, the last line gives a clue where to place it:


## Redirects go here

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=1083%3A-q-festq-qq&catid=255%3A2010-09-24-11-14-31&lang=ua
RewriteRule ^(index\.php)?$ http://example.com/index.php?option=com_content&view=article&id=1082&Itemid=348&lang=ua [R=301,L]


########## Begin - Joomla! core SEF Section
truemaker




msg:4271506
 2:56 pm on Feb 24, 2011 (gmt 0)

Perfect! It Works!
Great thanks!

And some more please.
If I use external link [----.com...]
I will see page as [----.com...] + query_string of my domain
How i can 301 redirect on ABSOLUTE URL without old query_string in target.

Maybe I should put a symbol at the end of the target URL ?

WBR
truemaker

g1smd




msg:4271589
 5:20 pm on Feb 24, 2011 (gmt 0)

Add a question mark to the redirect target URL to clear the query string.

Also posted that exact same answer in another thread
[webmasterworld.com...] just 4 minutes previously.

LukeDouglas




msg:4278728
 8:49 am on Mar 9, 2011 (gmt 0)

g1smd,

Thank you very much.

This works on a single link redirect for me:

RewriteCond %{QUERY_STRING} ^option=com_content&view=article&id=122:flyheadland-may-2008&catid=45:current-websites&Itemid=56

RewriteRule ^(index\.php)?$ [webbering.com...] [R=301,L]

Without the '?' on the end of the redirect link, it gave me a loop error as the query string was appended onto the end of the redirect link. Once I added the '?', it worked fine.

This solution has been one that I have been looking and working on for well over three months! If I knew your home address, I'd ship you a bunch of home baked cookies! :)

Thanks again.

Luke

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved