0

I would like that .htaccess recognize string in my url and replace it with another. Previously I used SEO components, but today I want to use Joomla native seo, and I have different structure of my url addresses.

I would like to get folder1 replaced with folder3 automatically when browser try to access it.

Example: www.domain.com/folder1/folder2/folder4/article-title-1 to www.domain.com/folder3/folder2/folder4/article-title-1

Any of the folder* doesn't exist on my server and links are generated by Joomla menu structures with SEO configuration ON.

I've tried to use code below but without success.

RewriteRule ^/?folder1([a-z/.]*)$ /folder3$1 [R=301,L]

1 Answer 1

1

htaccess will not give you proper result as this doesn't rewrite $_SERVER['REQUEST_URI'] so Joomla routing works with bad URI

What will help is creating system plugin and replace this variable in onAfterInitialise function


if you don't need to save the URL you can use something from here http://www.inmotionhosting.com/support/website/redirects/setting-up-a-301-permanent-redirect-via-htaccess


your htaccess rule will be

RewriteRule ^folder1(/.*)$ /folder3$1 [R=301,L]
10
  • Mmaybe there is different code that can be used. What I have shown above is something that I have used but not sure if it is wrong. Creating plugin, bit advanced...
    – stvlada
    May 28, 2016 at 16:39
  • Well, yes maybe I was to deep in it ) it was for more advanced task, if you didn't need to say URL - you may use standard htaccess redirect rule
    – Alexandr
    May 28, 2016 at 17:13
  • I've updated my answer
    – Alexandr
    May 28, 2016 at 17:16
  • thank you for your update but doesn't say anything about how to find one string and replace it with another. just for the reminder, these are SEO menu items, not actual folders located on server. I need htaccess rewrite/redirect rule that will find one word and just replace it with another, like it shown on my post.
    – stvlada
    May 28, 2016 at 20:58
  • And overall if you want to test your redirect - you can use this service htaccess.mwl.be
    – Alexandr
    May 28, 2016 at 22:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.