Search
Other ReReplacer questions
Forum

Replace in each header

Raimo Lindner's Avatar Raimo Lindner
Hello

I have a little bit special question.

I have the site www.reparaturfuehrer.ch/de . This in german. Then I have a french version www.reparateurs.ch/fr and a italian version www.riparatori.ch/it . On all domains is the same physical server behind with www.reparaturfuhrer.ch/de via DNS configuration.

I try to replace on each site in the header the following:
<link href="https://reparaturfuehrer.ch/de/wissen" rel="alternate" hreflang="DE">
<link href="https://reparaturfuehrer.ch/fr/savoir" rel="alternate" hreflang="FR">
<link href="https://reparaturfuehrer.ch/it/sapere" rel="alternate" hreflang="IT">

with:
<link href="https://reparaturfuehrer.ch/de/wissen" rel="alternate" hreflang="DE">
<link href="https://reparateurs.ch/fr/savoir" rel="alternate" hreflang="FR">
<link href="https://riparatori.ch/it/sapere" rel="alternate" hreflang="IT">

I think you see what I'm up to.

My search parameters are:
<link href="https://reparaturfuehrer\.ch/fr/([^"]+)" rel="alternate" hreflang="FR">

and I replace it with:
<link href="https://reperateurs.ch/fr/$1" rel="alternate" hreflang="FR">

So it should work on every different page with different URL.

Definied it is: Regular Expressions: YES
Search areas: Head / Enable HTML tags: YES
Conditions: none

Whatever I set in the Search areas, it doesn't work.

What could be the problem?

Thank you very much for any help!
Peter van Westen's Avatar Peter van Westen ADMIN
What happens if you simply replace:
reparaturfuehrer.ch/fr
With:
reperateurs.ch/fr
Please post a rating at the Joomla! Extensions Directory
Raimo Lindner's Avatar Raimo Lindner
Hello Peter

I don't know why I didn't come up with the simplest solution straight away 😉

It works like this, of course. Thank you for this tipp!

Unfortunately, something is still missing for the functioning language change.

I could solve it and perhaps it helps someone as a perfect solution for a multilanguage site with different domains.

The code I have with the normal Joomla inbuild multilanguage tool is:
<ul class=“lang-inline”>
	<li class=“lang-active” dir=“ltr”>
	   <a href=“/de/wissen”> <img title=“DE” src=“/media/mod_languages/images/de_de.gif” alt=“DE”> </a>
	</li>
	<li dir=“ltr”>
	   <a href=“/fr/savoir”> <img title=“FR” src=“/media/mod_languages/images/fr_fr.gif” alt=“FR”> </a>
	</li>
	<li dir=“ltr”>
       <a href=“/it/sapere”> <img title=“IT” src=“/media/mod_languages/images/it_it.gif” alt=“IT”> </a>
	</li>
 </ul>

I would have to add the domain to <a href= without changing the one behind it with:
search for:
<a href="(/fr/[^"]+)">

replace with:
<a href="https://reparateurs.ch$1">

Thank you again!
Peter van Westen's Avatar Peter van Westen ADMIN
Again, you don't need Regular Expressions for this. Keep it simple:
<a href="/fr/

replace with:
<a href="https://reparateurs.ch/fr/
Please post a rating at the Joomla! Extensions Directory
Raimo Lindner's Avatar Raimo Lindner
Yes, I see (again) 😉 You are absolutely right.

However: It's a fantastic and simple solution for multilanguage multidomain sites.
You should explicitly advertise it.
I've looked at countless tools and I haven't really found one that could solve my problem.
Peter van Westen's Avatar Peter van Westen ADMIN
ReReplacer is a "fantastic and simple solution" for a multitude of things 😁
Please post a rating at the Joomla! Extensions Directory
Raimo Lindner's Avatar Raimo Lindner
There is absolutely nothing to add to this 👍
Raimo Lindner's Avatar Raimo Lindner
I have encountered another problem...

There is another entry in the header
<link href="https://reparaturfuehrer.ch/de/wissen" rel="alternate" hreflang="x-default">
which is on reparateurs.ch/fr/savoir as well as on riparatori.ch/it/sapere

I don't just bring it in like that in the above case
<link href="https://reparateurs.ch/fr/savoir" rel="alternate" hreflang="x-default">
or
<link href="https://riparatori.ch/it/sapere" rel="alternate" hreflang="x-default">

When replacing, is there perhaps the possibility of doing something similar to
<link href="current browser URL" rel="alternate" hreflang="x-default">

and define the following for searching
<link href="https:\/\/reparaturfuehrer\.ch\/de\/(.*?)" rel="alternate" hreflang="x-default">

This seems to me to be a difficult case...
Peter van Westen's Avatar Peter van Westen ADMIN
You can get the current url via php, and place that inside the replacement. Make sure you have the 'treat as php' option on.
Please post a rating at the Joomla! Extensions Directory
Raimo Lindner's Avatar Raimo Lindner
Sounds great, but I have absolutely no idea how to do it. Any tips would be greatly appreciated.
Raimo Lindner's Avatar Raimo Lindner
However, after researching in more detail what hreflang=“x-default” actually is and does, I decided to leave the entry in its original form.

However, there are many other things you can do with this code.
In any case, I have saved it. You never know 😉

The actual code is/was:
<link href="https://reparateurs.ch/de/wissen" rel="alternate" hreflang="x-default">

After replacing I have/had:
<link href="https://reparateurs.ch/fr/savoir" rel="alternate" hreflang="x-default">

Searching for:
<link href="https:\/\/reparateurs\.ch\/de\/[^"]*" rel="alternate" hreflang="x-default">

Replacing with:
<link href="<?php echo JUri::getInstance()->toString(); ?>" rel="alternate" hreflang="x-default">
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription