isapi rewrite rules remove blog from wordpress url - apache

while i am new to rewrite I will try to outline this problem in english first than start a thread on how to fix this issue with all your help.
I am trying to remove the folder /blog/ from the following url:
http://blog.site.com/blog/2011/05/26/article-name-test/
with:
http://blog.site.com/2011/05/26/article-name-test/

Put this code in your .htaccess file:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteRule ^blog/?(.*)$ /$1 [R=301,L,NE,NC]
Update: Based on your comments
Here is your suggested .htaccess:
RewriteCond %{HTTP_HOST} ^www\.site\.me$ [NC]
RewriteRule ^ http://site.me%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^holisticho\.me$ [NC]
RewriteRule ^blog/ http://blog.site.me [R=301,L,NC]
Chris Hough Current Edits
Options +FollowSymlinks -MultiViews -Indexes
# ------------------------------------------------------------
# Core rewrite rules
# -----------------------------------------------------------
RewriteEngine on
# -----------------------------------------------------------
# Redirect deleting leading www to root domain if no specified sub is used:
# Allowed Subs: our, test, test.blog, local, local.blog
# -----------------------------------------------------------
RewriteCond %{HTTP_HOST} !^(our|test|test\.blog|local|local\.blog)\.holisticho\.me$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.holisticho\.me$
RewriteRule ^(.*)$ http://holisticho.me/$1 [R=301,L]4
# -----------------------------------------------------------
# Temporary Base Redirect Until Phase One Has been completed
# -----------------------------------------------------------
RewriteCond %{HTTP_HOST} ^holisticho\.me$ [NC]
RewriteRule ^(.*)$ http://our.holisticho.me/$1 [R=301,L]
# -----------------------------------------------------------
# Redirect Any Domains not speficied using /blog/ to the primary url for the blog
# -----------------------------------------------------------
RewriteCond %{HTTP_HOST} ^(test|local)\.holisticho\.me$ [NC]
RewriteCond %{REQUEST_URI} ^/blog/$ [NC]
RewriteRule (.*) http://our.holisticho.me/ [R=301,L]
# -----------------------------------------------------------
# User can use /login or /admin to log into WP
# -----------------------------------------------------------
RewriteCond %{HTTP_HOST} ^(our|test\.blog|local\.blog)\.holisticho\.me$ [NC]
RewriteRule ^(login|admin)$ http://%{HTTP_HOST}/blog/wp-login.php [NC,L]
# -----------------------------------------------------------
# If the wp-admin redirect is triggered redirect to the log in page with no query string
# -----------------------------------------------------------
RewriteCond %{HTTP_HOST} ^(our|test\.blog|local\.blog)\.holisticho\.me$ [NC]
RewriteCond %{REQUEST_URI} wp-login [NC]
RewriteCond %{QUERY_STRING} redirect_to [NC]
RewriteRule () http://%{HTTP_HOST}/blog/wp-login.php$1? [R=permanent,NC,L]
# -----------------------------------------------------------
# Add hidden "/blog/" to the url structure
# -----------------------------------------------------------
RewriteCond %{HTTP_HOST} ^(our|test\.blog|local\.blog)\.holisticho\.me$ [NC]
RewriteRule !^blog/ blog%{REQUEST_URI} [L,NE,NC]
# -----------------------------------------------------------
# Wordpress Permalink formatting
# -----------------------------------------------------------
RewriteCond %{HTTP_HOST} ^(our|test\.blog|local\.blog)\.holisticho\.me$ [NC]
RewriteRule ^index\.php$ - [L,NE,NC]
RewriteCond %{HTTP_HOST} ^(our|test\.blog|local\.blog)\.holisticho\.me$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,NE,NC]
# -----------------------------------------------------------
# Site Wide Error Controllers
# -----------------------------------------------------------
ErrorDocument 400 /400.php
ErrorDocument 401 /401.php
ErrorDocument 402 /402.php
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
# -----------------------------------------------------------
# Using browser cache: FileETag MTime Size
# -----------------------------------------------------------
<ifmodule mod_expires.c>
<filesmatch "\.(jpg|gif|png|css|js)$">
ExpiresActive on
ExpiresDefault "access plus 1 year"
</filesmatch>
</ifmodule>
# -----------------------------------------------------------
# Compress static data
# -----------------------------------------------------------
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
# -----------------------------------------------------------
# Protect blog from hotlinking
# -----------------------------------------------------------
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?holisticho\.me/ [NC]
RewriteCond %{HTTP_REFERER} !^$
#Replace /images/nohotlink.jpg with your "don't hotlink" image url
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /includes/images/administrative/NoHotlinking.png [L]
# -----------------------------------------------------------
# Fix for infinite loops
# -----------------------------------------------------------
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
# -----------------------------------------------------------

Related

Htaccess with special character

I would like to do a redirection through the htaccess :
Old URL :
http://www.website.com/?p=5729
New URL :
http://www.website.com/jmsblog/notrevie/18_charlie-raconte-les-chaussettes-qui-puent.html
So I do this in htaccess :
redirect 301 /?p=5729 http://www.website.com/jmsblog/notrevie/18_charlie-raconte-les-chaussettes-qui-puent.html
But it doesn't work, probably because of special character.
Someone as an idea?
***** EDIT ***********
Here is the htaccess file :
# ~~start~~ Do not remove this comment, Prestashop will keep automatically
the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source
solution
# http://www.prestashop.com - http://www.prestashop.com/forums
<IfModule mod_rewrite.c>
<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>
RewriteEngine on
#Domain: www.charlieetjune.com
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api$ api/ [L]
RewriteRule ^api/(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1
[QSA,L]
# Images
RewriteRule ^([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %
{ENV:REWRITEBASE}img/p/$1/$1$2$3.jpg [L]
RewriteRule ^([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %
{ENV:REWRITEBASE}img/p/$1/$2/$1$2$3$4.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %
{ENV:REWRITEBASE}img/p/$1/$2/$3/$1$2$3$4$5.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg [L]
RewriteRule ^([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg [L]
RewriteRule ^c/([0-9]+)(\-[\.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2$3.jpg [L]
RewriteRule ^c/([a-zA-Z_-]+)(-[0-9]+)?/.+\.jpg$ %{ENV:REWRITEBASE}img/c/$1$2.jpg [L]
# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]
# Dispatcher
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
</IfModule>
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff .woff
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|svg)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404
# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
RewriteCond %{THE_REQUEST} /\?p=5729
RewriteRule ^$ http://www.charlieetjune.com/jmsblog/notrevie/18_charlie-raconte-les-chaussettes-qui-puent.html? [L,R]
You can not Redirect Querystring using Redirect directive. You need to use the following Rule :
RewriteEngine on
RewriteCond %{THE_REQUEST} /\?p=5729
RewriteRule ^$ http://example.com/path/? [L,R]
Don't forget to include the ? at the end of the destination url as it removes the old querystring.

php access to page forbidden

hi am getting strange forbidden access message , anybody have any idea , its malware work or htaccess problem .
when i visit http://e-innovate.co.uk it give me angry response :)
Access to this page is forbidden. Sorry.
Sorry, but access to this page is forbidden. Even if you have authentication, you are still not allowed to access this page. It's not meant for your eyes - ever!
Check the URL you entered for any mistakes and try again. Alternatively, search for whatever is missing or take a look around the rest of our site.
here is my htaccess file
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options +MultiViews
</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
</IfModule>
ErrorDocument 401 /Error-401
ErrorDocument 403 /Error-403
ErrorDocument 404 /Error-404
ErrorDocument 500 /Error-500
ErrorDocument 503 /Error-503
# Disable directory browsing
Options All +Indexes
# Remove Trailing slash on url - START
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$ /$1 [R=301,L]
# Remove Trailing slash on url -END
RewriteCond %{HTTP_HOST} ^dksbsolutions\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.dksbsolutions\.co\.uk$
#RewriteRule ^/?$ "http\:\/\/www\.e\-innovate\.co\.uk" [R=301,L]
RewriteCond %{HTTP_HOST} ^dksbsolutions\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.dksbsolutions\.com$
#RewriteRule ^/?$ "http\:\/\/www\.e\-innovate\.co\.uk" [R=301,L]
RewriteCond %{HTTP_HOST} ^dksbsolutions\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.dksbsolutions\.uk$
#RewriteRule ^/?$ "http\:\/\/www\.e\-innovate\.co\.uk" [R=301,L]
# Redirect www. to non www. - START
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Redirect www. to non www. - END
# HTTP Keep Alive - Start
<ifModule mod_headers.c>
Header set Connection keep-alive
Header set Vary "Accept-Encoding"
</ifModule>
# HTTP Keep Alive - End
ExpiresActive On
# Set a max-age of one day for caches
<IfModule mod_headers.c>
Header set Cache-Control "max-age=86400"
</IfModule>
# cache images and flash content for one month
<FilesMatch ".(js|css|flv|gif|jpg|jpeg|png|ico|swf|woff)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# cache text, css, and javascript files for one week
<FilesMatch ".(pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# cache html and htm files for one day
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
# CACHE - END
#GZIP BEGIN - COMPRESS - .CSS .JS .HTML .XHTML .PHP .TXT
<ifModule mod_deflate.c>
<filesMatch "\.(css|js|x?html?|php|txt|eot|svg|woff)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>
# GZIP END
# DISABLE IMAGE HOT LINKING - START
# RewriteCond %{HTTP_REFERER} !^$
# RewriteCond %{SERVER_NAME}%{HTTP_REFERER} !^(.*)https?://\1/
# RewriteRule \.(js|css|png|jpg|jpeg) - [R=404,L]
# DISABLE IMAGE HOT LINKING - END
#DENY ACCESS - START
<FilesMatch "db.php|php_error.php|error_log|\.tpl$">
Order allow,deny
Deny from all
</FilesMatch>
#DENY ACCESS - END
# STRONG HTACCESS PROTECTION
<Files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</Files>
### Security - Disable HTTP Track and Trace
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
# 5G BLACKLIST/FIREWALL (2013)
# # http://perishablepress.com/5g-blacklist-2013/
# 5G:[QUERY STRINGS]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (\"|%22).*(<|>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (javascript:).*(\;) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (\\|\.\./|`|=\'$|=%27$) [NC,OR]
RewriteCond %{QUERY_STRING} (\;|\'|\"|%22).*(union|select|insert|drop|update|md5|benchmark|or|and|if) [NC,OR]
RewriteCond %{QUERY_STRING} (base64_encode|localhost|mosconfig) [NC,OR]
RewriteCond %{QUERY_STRING} (boot\.ini|echo.*kae|etc/passwd) [NC,OR]
RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC]
RewriteRule .* - [F]
</IfModule>
# 5G:[REQUEST METHOD]
<ifModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
# 5G:[BAD IPS]
<limit GET POST PUT>
Order Allow,Deny
Allow from all
# uncomment/edit/repeat next line to block IPs
# Deny from 123.456.789
</limit>
It seems that there is a permission/ownership issue for your files/folders. You cannot check Apache error log without root access. You should contact your host to investigate the root cause of this issue by checking Apache error log.
It is also possible that your host has changed server PHP/apache configurations which has caused this issue.

Redirect www to non-www not working

I'm trying to redirect from www.mydomain.com to mydomain.com but I keep failing. I used default Laravel htaccess file and I modified it to remove www from my links.
Can someone tell me what's wrong here:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<IfModule mod_deflate.c>
<FilesMatch "\.(html|php|txt|xml|js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>

Why aren't my internal links working

Basically, without this code in my .htaccess file, none of my internal links on my site work.
But with it in my .htaccess file, I am recieving a ton of HTTP/1.1 500 errors and a few 302 errors.
This is the code:
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule .* index.php [L]
I tried changing %{REQUEST_URI} to %{HTTP_HOST}. That fixed the internal link problem, but the errors are still there.
How would I modify this to remove all the errors I am receiving, and so that my internal links work?
PS. My site in built in Joomla.
If needed, this is my full .htaccess file":
Options +FollowSymLinks
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 30 days"
</IfModule>
Header unset ETag
FileETag None
</FilesMatch>
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteCond %{HTTP_HOST} !^(m)\.candoboatloans\.com\.au
RewriteCond %{HTTP_HOST} !^www\.candoboatloans\.com\.au
RewriteRule (.*) http://www.candoboatloans.com.au/$1 [R=301,L]
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteCond %{HTTP_HOST} !^(m)\.candoboatloans\.com\.au/index.php
RewriteRule ^(.*)index.php$ http://www.candoboatloans.com.au/$1 [R=301,L]
RewriteRule ^(.*)\.htm$ $1.html [L]
#RewriteBase /
RewriteCond %{HTTP_HOST} !^/index\.php
RewriteRule .* index.php [L]
# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]
# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]
# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]
# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile} !^$
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie} !\mobile=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.candoboatloans.com.au%{REQUEST_URI} [R,L]
Give this a try, its based of joomla's default .htaccess with the needed parts from your .htaccess:
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 30 days"
</IfModule>
Header unset ETag
FileETag None
</FilesMatch>
#####################################################
# 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 disallows 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
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
RewriteBase /
# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]
# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]
# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]
# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile} !^$
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie} !\mobile=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.candoboatloans.com.au%{REQUEST_URI} [R,L]
# Redirect to www if not www.domain or m.domain
RewriteCond %{HTTP_HOST} !^(m)\.candoboatloans\.com\.au
RewriteCond %{HTTP_HOST} !^www\.candoboatloans\.com\.au
RewriteRule (.*) http://www.candoboatloans.com.au/$1 [R=301,L]
# If it ends with index.php and is not m.domain redirect to www.domain.com/content
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteCond %{HTTP_HOST} !^(m)\.candoboatloans\.com\.au$
RewriteRule ^(.*)index.php$ http://www.candoboatloans.com.au/$1 [R=301,L]
# Redirect all variations of index and default to www.domain.com/
# exception of index.php which should not be redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(default|index)\.(s?html?|pl|aspx?|cfm)[\s]+ [NC]
RewriteRule ^ /? [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 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 - 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

Remove trailing slash after domain

This is my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Remove multiple slashes anywhere in URL
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
# Never use www prefix!
RewriteCond %{HTTP_HOST} ^www.domain\.org [NC]
RewriteRule (.*) http://domain.org/$1 [R=301,L]
# Remove multiple slashes after domain
RewriteRule ^/(.*)$ http://domain.org/$1 [R=301,L]
# Remove trailing slash in some cases
RewriteRule ^(.*)\.css/$ http://domain.org/$1.css [L,R=301]
RewriteRule ^(.*)\.js/$ http://domain.org/$1.js [L,R=301]
RewriteRule ^(.*)\.jpg/$ http://domain.org/$1.jpg [L,R=301]
RewriteRule ^(.*)\.jpeg/$ http://domain.org/$1.jpeg [L,R=301]
RewriteRule ^(.*)\.png/$ http://domain.org/$1.png [L,R=301]
RewriteRule ^(.*)\.gif/$ http://domain.org/$1.gif [L,R=301]
RewriteRule ^(.*)\.xml/$ http://domain.org/$1.xml [L,R=301]
# Force trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)\.css
RewriteCond %{REQUEST_URI} !(.*)\.js
RewriteCond %{REQUEST_URI} !(.*)\.jpg
RewriteCond %{REQUEST_URI} !(.*)\.jpeg
RewriteCond %{REQUEST_URI} !(.*)\.png
RewriteCond %{REQUEST_URI} !(.*)\.gif
RewriteCond %{REQUEST_URI} !(.*)\.xml
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://mydomain.org/$1/ [L,R=301]
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
# MIME types
AddType text/css .css
AddType text/javascript .js
# Enable compression
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript text/x-css text/x-javascript text/x-js text/htm application/x-javascript application/javascript application/js application/x-js image/png image/gif image/jpg image/jpeg
#Skip browsers with known problems
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
php_flag display_errors on
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
But, when I go to **/////, the trailing slashes will not go away. What am I doing wrong?
The %{REQUEST_URI} variable gets reduced of extra slashes when it gets prepped. So the condition RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ will never match because for a request like http://domain.org////, the REQUEST_URI variable gets reduced to just /. Try using the THE_REQUEST variable:
RewriteCond %{THE_REQUEST} ^([A-Z]{3,9})\ (.*)//([^\ ]*)
RewriteRule ^ %2/%3 [R=301,L]
Additionally, the prefix (the leading slash) gets stripped off of the request URI when rewrite rules are in an htaccess file, so the rule RewriteRule . %1/%2 [R=301,L] would never match because the regex . requires at least one character to match. When the URI is / and the leading slash gets stripped, the URI that's used to match in the url is a blank string. So using ^, or (.*), or something equivalent of "everything including nothing" regex needs to be used.