Support

Admin Tools

#40329 Import redirect urls in htaccess

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 houba_houbi on Monday, 04 March 2024 12:40 CST

houba_houbi

Hello

I am new with admintools app, so before in my htaccess I write rules for 301 redirections (when urls changes) :

Redirect permanent /aaa https://www.mywebsite.fr/abb
...etc
Redirect permanent /sitemap.xml https://www.mywebsite.fr/component/osmap/?view=xml&id=1&format=xml

I prepare my rules and import all the lines in my htaccess file

But now with admintools, there is a URL Redirection tool, but I need to create each line one by one, so it will be long. Is there a way to import all my rules easily ? Thanks

 

 

 

nicholas
Akeeba Staff
Manager

There is no interface in Admin Tools itself to do that, but you can always manipulate the #__admintools_redirects table directly. The source column is the URL which you can access on your site, without a redirection. The dest is the URL path which when visited will cause a redirection to the source.

So, let's say my site is https://www.example.com. if I set source to /home/news.html and dest to latest-news what I am telling Admin Tools is anyone visiting https://www.example.com/latest-news will be redirected to https://www.example.com/home/news.html.

Knowing that, you can create a spreadsheet (in Microsoft Excel, LibreOffice Calc, Apple Numbers, Google Sheets, etc) with the source and dest pairs. Make sure that row 1 has the source and dest headers. Export that to CSV, and you can now import it into the #__admintools_redirects table using phpMyAdmin or any similar database management tool your host provides.

If you mess up, no worries. Empty that table, and start over.

Pro tip: keep a copy of that spreadsheet in its spreadsheet (not CSV) form. In a couple of years when you want to restructure your site it will be so much easier figuring out redirections having a good starting point in a format you can easily manage.

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!

houba_houbi

Bonjour Nicolas,

Merci d'avoir partagé cette astuce. Cela fonctionne très bien mais il est curieux que le nom de colonne dans la base de données pour la source et la destination soit en fait inversé dans Joomla. J'ai dû inverser mes données.

nicholas
Akeeba Staff
Manager

If you look at the source code of the form when editing a redirection you will see this:

<div class="control-group">
<div class="control-label"><label id="jform_dest-lbl" for="jform_dest">
Visiting this</label>
</div>
<div class="controls">

<div class="input-group has-success">

<span class="input-group-text">https://boot5.local.web/</span>
<input type="text" name="jform[dest]" id="jform_dest" value="en/malakia/test?foobar=1"
class="form-control valid form-control-success" aria-describedby="jform_dest-desc"
aria-invalid="false">


</div>

<div id="jform_dest-desc" class="hide-aware-inline-help d-none">
<small class="form-text">
This is a relative URL on your site. When someone visits it they will be redirected to the “Takes you
there” URL below. It must not have the http:// or https:// protocol prefix, your domain name or a
leading slash. Examples: <code>search/on/google</code> or <code>456-blog/123-my-article</code>. Please
note that you cannot specify the fragment (the <code>#</code> sign in the URL and anything following it)
since this is a client-side feature; your server does NOT see the fragment, therefore we cannot make a
server-side redirection based on the fragment contents. </small>
</div>
</div>
</div>
<div class="control-group">
<div class="control-label"><label id="jform_source-lbl" for="jform_source">
Takes you here</label>
</div>
<div class="controls">


<input type="text" name="jform[source]" id="jform_source" value="/en/home/blog.html" class="form-control"
aria-describedby="jform_source-desc">


<div id="jform_source-desc" class="hide-aware-inline-help d-none">
<small class="form-text">
This is the relative or absolute URL where the visitor will be taken to. This URL must be valid even if
you turn off the redirection feature. It can be a URL to your own site or a different one. Examples:
<code>https://www.example.com</code> or <code>blog/123-my-article</code>. </small>
</div>
</div>
</div>

As you can see it says

  • target = Visiting This
  • source = Takes You Here

Just like I told you.

What you consider a "source" and what you consider a "target" depends on your perspective. Exactly half of the people understand that source is the URL that exists even without a redirection, whereas the other half understand that source is the URL which when visited triggers the redirection. There is no universally accepted explanation. To wit, Microsoft Windows uses the former understanding for its mklink tool, whereas UNIX systems (like Linux, FreeBSD, etc) use the latter explanation for their ln tool. Which is to say, both explanations are right and wrong at the same time, depending on who you ask. Confusing, isn't it?

It was confusing for clients, too. Half of them got it, the other half complained it's inverted. After figuring out that there is no way that everyone would understand the same way what source and target means, I changed the labels to Visiting This and Takes You Here. Now nobody gets confused. The database and the code still use source and target because these two things only need to be understood by me and Davide, the two developers of the software :)

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!

houba_houbi

Oh yes effectively it's confusing :) With your label "visit this" "takes you here" it's very clear ! Thanks

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!