skip to Main Content

I’m trying to understand how to redirect some urls that on my new site are not yet active but redirect a few other to new imported page on my new website
Example

I have and joomla website i’d like to redirect
www.mywebsite.it/it to old.mywebsite.it/it

But have also some spercific 301 redirects for news and some page
it/notizie/2036-slugnews.html to notizie/year/notizia/slugnews

I’m working on Apache2, with mysql 5.7, php 7.2 and October Cms.
With mod_rewrite enabled and laravel

Read some examples on:
https://www.danielmorell.com/guides/htaccess-seo/redirects/introduction-to-redirects

Imagined i have to try to write a condition that get all urls after /it/*but insert an exception to write all except the ones with 301 redirects

Honestly can’t figure out how to redirect write the condition.

Have you some suggestions?

2

Answers


  1. Chosen as BEST ANSWER

    after a series on trials i have found an intermediate solution:

    RedirectMatch 301 ^/it(.*)$ https://www.mysite.it$1
    RewriteRule ^it/genericpage.html https://www.mywebiste.it/genericapagetoredirect? [R=301,L]
    RewriteRule ^it/notizie/2002-slug.html https://www.mywebiste.it/notizie/2019/notizia/slugtoberedirected? [R=301,L]
    

    In this way i redirect my old https://www.mysite.it/it home page to https://www.mysite.it and some urls with a one to one redirect

    But is not my goal.

    Reasoning on the subject i found the defnitive solution

    My goal is to redirect 1) a bunch of url with a rewrite url 301 2) All the links which are not included in the list of rewrite url genrically to https://www.mysite.it 3) All bad link joomla website create from www.mysite.it/it/tags/* and www.mysite.it/it/components/* to www.mysite.it

    In general the goal frankly is to mantain linked urls with high authority in the google search console.

    Aware of this i tried to

        RewriteRule ^it/genericpage.html$ https://www.mywebiste.it/genericapage? [R=301,L]
        RewriteCond %{HTTPS_HOST} ^www.mysite.it$
        RewriteRule ^it/$ https://www.mysite.it/? [R=301,L]
    

    and

        RewriteRule ^it/genericpage.html$ https://www.mywebiste.it/genericapage?[R=301,L]
        RewriteCond %{HTTPS_HOST} ^www.mysite.it$
        RewriteRule ^it(/.*) $1 [R=301,L]
    

    But without success.

    What do you think?


  2. You should place your special url redirects before general rule in your .htaccess file:
    For example:

    RewriteEngine on
    RewriteRule ^it/notizie/2036-slugnews.html$ http://old.mywebsite.it/notizie/year/notizia/slugnews? [R=301,L]
    RewriteCond %{HTTP_HOST} ^www.mywebsite.it$
    RewriteRule ^(.*)$ http://old.mywebsite.it/$1 [R=301,L]
    

    If You new to redirects, I can suggest to use https://www.301-redirect.online/ 301 redirect generator for your special page to page rules. This generator is the best one I know at this moment.

    Also, change http:// to https:// if your site uses secure connection.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search