how to redirect 301 to new Domain without Broken links

i need htaccess code for redirect to new Domain without Broken links.

note:

remove space in url.

my Rules:


'urlManager' => [

            /*'suffix' => '.htm',*/

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'rules' => [

                // your url config rules

                'htt p://ww w.sample.com/<controller>/play/<id:\d+>' => '<controller>/play',

                '<controller>/<id:\d+>' => '<controller>/view',

                '<controller:(mp3|album|video|artist|news|podcast|playlist)>/page/<page:\d+>' => '<controller>/index',

                '<controller:(mp3|album|video|playlist|podcast)>/html/<id:\d+>' => '<controller>/html',

                '<controller:(tag)>/<tag>/page/<page:\d+>' => '<controller>/index',

                'tag/<tag>' => 'tag/index',

                'admin/<controller>/<action>'=>'<controller>/admin-<action>',

            ],

i use this code in htaccess:




RewriteCond %{HTTP_HOST} ^old.ir$ [OR]

RewriteCond %{HTTP_HOST} ^ww w.old.ir$

RewriteRule (.*)$ htt p://ww w.new.org/$1 [R=301,L]

but result is Broken links.

old link:


htt p://ww w.old.ir/mp3/3802

after redirect:


htt p://ww w.roozic.org/index.php/3802

why index.php? mp3 is Correct.