Forum Moderators: phranque

Message Too Old, No Replies

Redirect old url's

Redirect old url's

         

izilus

2:02 pm on Jun 22, 2017 (gmt 0)

5+ Year Member



Hello.
Due to migration to the new cms, it became necessary to redirect old URLs. When redirecting, it's enough to use part of the URL. For example, the necessary part of URL site.com/p3660664-shtangentsirkul-shts.html is only /p3660664-
Redirect 301 /p3660664-(.*) /index.php?route=product/product&path=530869&product_id=3660664
RewriteCond %{QUERY_STRING} ^route=product/product&path=530869&product_id=3660664$
RewriteRule ^index\.php /p3660664-shts-shtangentsirkul? [R=301,L]

Using this method, the result was not achieved. CMS - opencart.

What am I doing wrong and how do I fix it please ?

Thanks very much

lucy24

4:32 pm on Jun 22, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What am I doing wrong

The blatant big mistake is combining mod_alias (Redirect by that name) with mod_rewrite. You have no control over which module executes first (ordinarily it's mod_rewrite) so your first step is to change all existing mod_alias directives to use mod_rewrite syntax.

(Would Redirect 301 followed by a Regular Expression even work? Best case, the (.*) would be interpreted as a literal string, so the rule will simply fail to execute, ever.)

Start by reading some of the existing posts in this thread, and maybe anything linked from the forum library.

phranque

12:22 am on Jun 23, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, izilus! [webmasterworld.com]

it appears to me you have a situation with old external urls that were being internally rewritten to an index.php script and now the old external urls must be redirected to the new external urls.
in order to help we need to understand the patterns of all 3 sets of urls and how they relate.

izilus

9:56 am on Jun 23, 2017 (gmt 0)

5+ Year Member



Thanks to all, I solved my problem this way
RedirectMatch permanent /p503947-(.*).(?:htm|html) /index.php?route=product/product&path=416699&product_id=503947