Support

Admin Tools

#10033 .htaccess & cPanle ReDirects

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by nicholas on Saturday, 24 September 2011 16:34 CDT

earthrat

I am using the Admin Tools .htaccess tool and I have an old html website that I converted to a Joomla site. I created all the redirects in cPanel to send these old pages to the new ones but I have traced what I think is an issue with the .htaccess file I generated. What parameters do I need to change so that the cPanel redirects will work to point these old addresses to the new Joomla ones without throwing a 404 error?

earthrat
Correct me if I am wrong but I think I need to comment out the following in order to make the redirects work?

# 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]
#

rkendallc
What I found with redirects is that they need to be placed at the top of the file. If you redirect a domain name, like .com to .org, it doesn't work completely unless it is above all the Joomla redirections. Many times, the coding in the .htaccess will remove parts so that the redirection at the end does not function.

CPanel seems to always add it to the end. Try moving it above all the Joomla entries and see if that helps to make the redirects happen without 404 errors.

earthrat
You sir are a lifesaver, that is exactly what I had to do...

Thank so much you just saved my bacon big time!!!

nicholas
Akeeba Staff
Manager
I have to warn you that putting a lot (over 50) redirections in the .htaccess file causes observable performance loss. The .htaccess file is read to memory, parsed and executed for each and every request sent to the browser, even for static files like CSS, Javascript, images, videos, etc. A typical page contains around 30 such items. If the redirects cause a 0.05 second delay, then the whole thing adds up 0.05 * 30 = 1.5 seconds to the page load time. The slower the server, the busiest the site, the more the static files and the more redirections you have, the worse the problem gets.

I would strongly recommend using either Admin Tools Professional's URL redirection feature, or Joomla! 1.6/1.7's Redirection core component to implement the redirections. This way, the redirections are only parsed for the HTML content, not for static resources. If you have over 50 redirections, using this kind of redirections gives you a measurable speed boost. Believe me, I have 400 redirections set up on this site and I know what the impact is ;)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

earthrat
That is very important on this site where we currently have over 500 redirects built and estimate 300 more that need to be done. The site is currently experiencing on average of 89,000 hits per day so I know I need to make some immediate adjustments based on your recommendation.

One question though, I read the documentation on using Admin Tools redirection and it looked like this was to redirect an existing Joomla page to a shorter URL. What I have is we moved from a static html site to Joomla so the pages I am moving from have no reference in Joomla. Did I read that right or will I still be able to use Admin Tools to setup all my redirects?

This will be fantastic and a concern I have with putting the redirects above all the Joomla code in the htaccess file is it seems to me that this would break the security features since these pages are referenced before the security parameters. Is that something I should be concerned about or am I to far out of the box with my reasoning?

nicholas
Akeeba Staff
Manager
Unlike SEF extensions, Admin Tools' redirection feature can be used to redirect to any URL, even one not belonging to your site. You can actually use it to create your own, pricate short URL service. There are no limits.

Security is not a concern here. The URL is rediected, then the security kicks in on the redirected URL. It's the same thing as using, say, bit.ly to create a short URL to your site. What your browser does, transparently, is to perform two requests: the initial request to the page responds with a redirection header, then the browser performs a new request to the new URL. As long as your server is concerned, the second request is processed like any other request coming to it.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

earthrat
Thanks Nico, this is a huge help for me and I now know what I will be doing this weekend instead of fishing (Thanks A Lot;)...LOL

earthrat
This is working great Nico but I would like to point out that it seems counter-intuitive. What I mean is that (at least the way I view it) the Existing URL should be URL you want to redirect, where you are redirecting to the "New URL". Or at least rename "New URL" to "Old URL" since in fact it is the old URL. To me it would make more sense to call the new page field I am going to direct to the "New URL" and the page I am moving away from the "Old URL".

(just food for thought;)

nicholas
Akeeba Staff
Manager
Well, it's about semantics. The labelling is guaranteed to confuse at least half of the people.

The existing URL is the URL which is valid no matter if you have Admin Tools' URL redirection set up or not. It already exists. It's there. Turn off the plugin and it is still there.

The New URL is the URL which didn't exist and you just created using this feature. Before setting it up, it would throw a 404 Not Found. If you turn off the plugin, it will still throw the 404.

Remember, that this feature is designed to perform any redirection, not simply redirect an old site's URLs to a new site's URLs. Even in this particular use case you have to think about it like that: does your old site's URL exist without the plugin? No, therefore it can not be an existing URL.

I originally thought of using "Source URL" and "Target URL" but it was even more counter-intuitive. If anyone has an idea for better wording, please tell me, I'm a little stuck here :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

earthrat
LOL, it’s all good and not unusual to find me in the wrong half...;) In the end it’s a matter of training and where I have so many to build I am convinced that I will defiantly know and understand your position by the time I finish..;)

nicholas
Akeeba Staff
Manager
For the record, I used to belong to the wrong half too :D However, the other half is the most loud, hence the naming of the fields. Plus, if you really think about it, it does make sense.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

earthrat
HaHa, yes i know that crowd very well...;)

I just did 500 and after finishing it does make more sense to me now. Thanks for all your hard work. Every time I work with your tools I am more impressed than the last...;)

nicholas
Akeeba Staff
Manager
Thank you for your kind words :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!