Joomla htaccess redirect to mobile site - .htaccess

I am trying to get this joomla site to redirect to a subdomain called mobile.backuptoweb.co.uk when used on mobile devices. But I also want to keep the existing rewrite rules that ensure all users are redirected to the www. url and trailing / are removed.
Currently it just redirects into an infinate loop when view on a mobile device.
htaccess:
##
# #package Joomla
# #copyright Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved.
# #license GNU General Public License version 2 or later; see LICENSE.txt
##
## 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 base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
# mobile site redirection
RewriteCond %{HTTP_REFERER} !^http://(.*).backuptoweb.co.uk/.*$ [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://mobile.backuptoweb.co.uk/$1 [L,R=302]
RewriteCond %{HTTP_HOST} ^backuptoweb.co.uk [NC]
RewriteRule ^(.*)$ http://www.backuptoweb.co.uk/$1 [L,R=301]
# index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
#
## End - Custom redirects
##
# 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}]
#
## End - Joomla! core SEF Section.

Would it be feasible to redirect all mobile traffic to your mobile subdomain and have a second .htaccess file there where you do the mobile tests and rewrites?
To check if I understand your comments correctly,
For non-mobile visitor
http://backuptoweb.co.uk/something redirects to http://www.backuptoweb.co.uk/something
For mobile visitor
http://backuptoweb.co.uk/something redirects to http://www.mobile.backuptoweb.co.uk/something
except if they are coming from your mobile site. If this is the case you want
http://backuptoweb.co.uk/something redirecting to http://www.backuptoweb.co.uk/something
What do you think of this for the logic and order?
Rewrite index.php to / (definitely don't use [L] flag)
Check if mobile visitor and coming from mobile site. If yes use Rewrite with [L] and send to http://www.backuptoweb.co.uk/something
Check if mobile visitor (and not coming from mobile site. If yes use Rewrite with [L] and send to http://www.backuptoweb.co.uk/something
Rewrite no-www to www.backuptoweb.co.uk/something with [R=301,L]
Some of the flags probably need work.
See how this works for you. Be sure to clear you browser cache as well when testing.
If there are any mod_rewrite gurus out there, I'd also welcome suggestions for improvement
Options +FollowSymLinks
RewriteEngine On
# Jooomla stuff here
# rewrite index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
# RewriteRule ^(([^/]+/)*)index\.php$ http://www.backuptoweb.co.uk$1 [R=301] *** updated
RewriteRule ^(([^/]+/)*)index\.php$ http://www.backuptoweb.co.uk/$1 [R=301]
# check if coming from mobile site
# if yes continue to main site
# RewriteCond %{HTTP_REFERER} ^http://www\.mobile\.backuptoweb\.co\.uk/ [NC] *** updated
RewriteCond %{HTTP_REFERER} ^http://mobile\.backuptoweb\.co\.uk/ [NC]
RewriteRule (.*) http://www.backuptoweb.co.uk$1 [R=301,L]
# send any remaining mobile visitors to mobile site
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{http_host} !^$
# RewriteRule (.*) http://www.mobile.backuptoweb.co.uk/$1 [R=301,L] *** updated
RewriteRule (.*) http://mobile.backuptoweb.co.uk/$1 [R=301,L]
# rewrite non-www to www
RewriteCond %{http_host} ^backuptoweb\.co\.uk$
RewriteCond %{http_host} !^$
RewriteRule (.*) http://www.backuptoweb.co.cuk/$1 [R=301,L]

Related

.htaccess - Block or redirect direct URL access to folder/files [duplicate]

Is there any way to Redirect a page from one page to another page without changing the url using htaccess in joomla?
I want to change the url
http://idaycom.com/index.php/component/quates/
to
http://idaycom.com/index.php/component/quotes/
How to change it ?
here is my htaccess file
##
# #version $Id: htaccess.txt 21101 2011-04-07 15:47:33Z dextercowley $
# #package Joomla
# #copyright Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
# #license GNU General Public License version 2 or later; see LICENSE.txt
##
##
# 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
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/index\.php/component/quates [NC]
RewriteRule .* index.php/component/quotes [R=301,L]
## 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 base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects
##
# 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 something within the component folder,
# or 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))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file 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.
You can try this one buddy:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
I used this on my website.
You may try this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/index\.php/component/quates [NC]
RewriteRule .* index.php/component/quotes [R=301,L]
Redirects permanently
http://idaycom.com/index.php/component/quates
To
http://idaycom.com/index.php/component/quotes
For silent mapping, replace [R=301,L] with [L]
you can try with many ways:
RedirectMatch "^/existingfile\.html/?$" "http://example.com/newfile.php"
this will redirect your existing url to new url

Conditional .htaccess redirects to subdomains

The logic of RewriteCond somehow continues to elude me, so maybe somebody could take a look at my current problem:
I have to sort a very (very) confusing page that has a quite poorly configured virtual domain system in place. The easiest way for the moment seems to be redirects in the .htaccess.
Basically, I want to express the following to mod_rewrite:
IF request string contains the directories /aaa or /bbb
AND the subdomain is not www. , THEN redirect the request to http://www.foo.com/ and keep any URI-parts that might follow, like/aaa/target-dir/index.html .
Same for /ddd: if subdomain is not sub1., redirect towards http://sub1.foo.com/ddd (as well as for 2 more subdomains).
My attempt so far was
RewriteCond %{HTTP_HOST} !^www\.foo\.com [NC]
RewriteCond %{REQUEST_URI} /aaa/|/bbb/
RewriteRule ^(.*)$ http://www\.foo\.com/%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^sub1\.foo\.com [NC]
RewriteCond %{REQUEST_URI} /ddd/|/eee/
RewriteRule ^(.*)$ http://sub1\.foo\.com/%{REQUEST_URI} [R=301,L]
but that did not work for some reason.
What's my mistake? Anyone got an idea?
edit: The complete .htaccess as follows
##
# #package Joomla
# #copyright Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved.
# #license GNU General Public License version 2 or later; see LICENSE.txt
##
##
# 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 base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects
##
# 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 something within the component folder,
# or 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))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file 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.
## OSMap Adjustment
RewriteCond %{REQUEST_URI} ^/sitemap.xml
RewriteRule .* /index.php?option=com_osmap&view=xml&tmpl=component&id=3
RewriteCond %{REQUEST_URI} ^/sub1-sitemap.xml
RewriteRule .* /index.php?option=com_osmap&view=xml&tmpl=component&id=1
RewriteCond %{REQUEST_URI} ^/sub2-sitemap.xml
RewriteRule .* /index.php?option=com_osmap&view=xml&tmpl=component&id=2
## Redirect non-www to www
RewriteCond %{HTTP_HOST} !^(www|sub1|sub2|sub3).foo.com$
RewriteRule ^(.*)$ http://www.foo.com/$1 [R=301,L]
## RewriteEngine On
## RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
## RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
## /aaa , /bbb => www.foo.com
RewriteCond %{HTTP_HOST} !^www\.foo\.com [NC]
RewriteCond %{REQUEST_URI} /aaa/|/bbb/
RewriteRule ^(.*)$ http://www\.foo\.com/%{REQUEST_URI} [R=301,L]
## /ddd, /eee => sub1.foo.com
RewriteCond %{HTTP_HOST} !^sub1\.foo\.com [NC]
RewriteCond %{REQUEST_URI} /ddd/|/eee/
RewriteRule ^(.*)$ http://sub1\.foo\.com/%{REQUEST_URI} [R=301,L]
## /fff, /ggg => sub2.foo.com
RewriteCond %{HTTP_HOST} !^sub2\.foo\.com [NC]
RewriteCond %{REQUEST_URI} /fff/|/ggg/
RewriteRule ^(.*)$ http://sub2\.foo\.com/%{REQUEST_URI} [R=301,L]

Redirect a page from one page to another page without changing the url using htaccess

Is there any way to Redirect a page from one page to another page without changing the url using htaccess in joomla?
I want to change the url
http://idaycom.com/index.php/component/quates/
to
http://idaycom.com/index.php/component/quotes/
How to change it ?
here is my htaccess file
##
# #version $Id: htaccess.txt 21101 2011-04-07 15:47:33Z dextercowley $
# #package Joomla
# #copyright Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
# #license GNU General Public License version 2 or later; see LICENSE.txt
##
##
# 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
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/index\.php/component/quates [NC]
RewriteRule .* index.php/component/quotes [R=301,L]
## 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 base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%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})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects
##
# 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 something within the component folder,
# or 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))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file 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.
You can try this one buddy:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
I used this on my website.
You may try this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/index\.php/component/quates [NC]
RewriteRule .* index.php/component/quotes [R=301,L]
Redirects permanently
http://idaycom.com/index.php/component/quates
To
http://idaycom.com/index.php/component/quotes
For silent mapping, replace [R=301,L] with [L]
you can try with many ways:
RedirectMatch "^/existingfile\.html/?$" "http://example.com/newfile.php"
this will redirect your existing url to new url

.htaccess URL rewriting issue

I am working on redirecting all files in the URI(?) www.gdlsk.com/practice to this new address:
http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html
I'd all of these examples to redirect to http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html:
http://www.gdlsk.com/practice
http://www.gdlsk.com/practice/
http://www.gdlsk.com/practice/*
Where * is wildcard. Want to catch any and all requests.
##
# #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 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!
#
## 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
#RewriteCond %{REQUEST_URI} !^/practice
#RewriteCond %{REQUEST_URI} !^/practice?$
#RewriteRule ^/practice http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html? [R=301,L]
#RewriteCond %{REQUEST_URI} !^/practice
#RewriteCond %{REQUEST_URI} !^/practice?$
#RewriteRule ^(.*)$ /customs-broker-regulation/customs-broker-exam-sign-up.html [R=301,L]
#RewriteRule ^/practice/ http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html [R=301,L]
#RewriteRule (/practice/.*) customs-broker-regulation/customs-broker-exam-sign-up.html
Redirect 301 /practice http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html
Redirect 301 /practice/highform.htm http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html
Redirect 301 /practice/highform.html http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html
I assume that you are typing query string params and you want to stop them being passed on the redirect. Add a ? to drop the query string parameters as below
RewriteRule ^/practice/ http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html? [R=301,L]
Edit.
Based on last update this should do the trick
RewriteCond %{REQUEST_URI} ^/practice [NC]
RewriteRule . http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html? [R=301,L]
Try using rewrites instead of redirects. For example:
RewriteEngine on
RewriteRule ^/practice/ http://www.gdlsk.com/customs-broker-regulation/customs-broker-exam-sign-up.html [R=301,L]

Proper .htaccess Method to Redirect a Few Select Pages to use HTTPS, Returning all Others to HTTP?

I've looked through similar questions but not found the exact working solution I'm after.
We have a Joomla site that needs 2-3 specific pages to be forced to use https, while navigating away from these pages needs to return to http for all other pages. All pages 'can' come up with either http or https, but https causes some issues with a few plugins.
We have already setup a few things on the .htaccess file, but I don't know all the syntax to do what I'm after. We have mod_rewrite on, a rule that redirects http:// to http://www., and the default Joomla rules that do the SEF urls.
So our secure pages are usually: /section/category/secure-page, /othersection/othercategory/secure-page 2, etc.
HERE'S OUR ENTIRE HTACCESS AFTER IMPLEMENTING THE FIX (BUT GETTING ERROR):
##
# #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
########## Begin - SSL Redirects (https/http)
#
RewriteRule %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cultivate-la-tickets$ [OR]
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-thankyou$ [OR]
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-decline$ [OR]
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-error$ [OR]
RewriteCond %{REQUEST_URI} ^/how-to-help/donate/make-a-donation/$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
RewriteRule %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/news-events/cultivate-la/cultivate-la-tickets$
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-thankyou$
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-decline$
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-error$
RewriteCond %{REQUEST_URI} ^/how-to-help/donate/make-a-donation/$
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L]
#
##########
########## Begin - Redirect http:// to http://www. AND /annual subdirectory to annual. subdomain
#
RewriteCond %{HTTP_HOST} ^domainname.org [NC]
RewriteRule ^(.*)$ http://www.domainname.org/$1 [L,R=301]
RedirectMatch 301 ^/annual/(.*)$ http://annual.domainname.org/$1
#
##########
# 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 - 301 Redirect short URL
#
Redirect 301 /clatickets https://www.domainname.org/news-events/cultivate-la/cultivate-la-tickets
note: I deleted my previous answer. it's my new answer:
##
# #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
########## Begin - SSL Redirects (https/http)
#
RewriteRule %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cultivate-la-tickets$ [OR]
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-thankyou$ [OR]
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-decline$ [OR]
RewriteCond %{REQUEST_URI} ^/news-events/cultivate-la/cla-tickets-error$ [OR]
RewriteCond %{REQUEST_URI} ^/how-to-help/donate/make-a-donation/$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
RewriteRule %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/news-events/cultivate-la/cultivate-la-tickets$
RewriteCond %{REQUEST_URI} !^/news-events/cultivate-la/cla-tickets-thankyou$
RewriteCond %{REQUEST_URI} !^/news-events/cultivate-la/cla-tickets-decline$
RewriteCond %{REQUEST_URI} !^/news-events/cultivate-la/cla-tickets-error$
RewriteCond %{REQUEST_URI} !^/how-to-help/donate/make-a-donation/$
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L]
#
##########
########## Begin - Redirect http:// to http://www. AND /annual subdirectory to annual. subdomain
#
RewriteCond %{HTTP_HOST} ^domainname.org [NC]
RewriteRule ^(.*)$ http://www.domainname.org/$1 [L,R=301]
RedirectMatch 301 ^/annual/(.*)$ http://annual.domainname.org/$1
#
##########
# 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 - 301 Redirect short URL
#
Redirect 301 /clatickets https://www.domainname.org/news-events/cultivate-la/cultivate-la-tickets
In case it helps anyone, our developer found a plugin for Joomla that forces certain pages to use HTTPS and all other to use HTTP. It has some other handy features as well. Not sure exactly what's going on behind the scenes, but it works great (where the .htaccess methods weren't) so we won't complain.
The plugin is called: Yireo SSL Redirection.
It can be found here: http://extensions.joomla.org/extensions/site-management/url-redirection/11326

Resources