微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

mod重写以更改域

如何解决mod重写以更改域

我正在尝试更改我的网址的域,父网址类似于

http://abc.def.com/123123132/abcvalue

我有一个规则

RewriteCond %{HTTP_HOST} ^abc\.def\.com$
RewriteRule ^(.*)$ https://efg.com/dd/as/$1 [L]

这正在更改域,但它也将旧域放入新 url 中。类似的东西

https://efg.com/dd/as/http://abc.def.com/123123132/abcvalue

需要这方面的帮助。谢谢

编辑:- 完整的 htaccess 是

    # PHP -- BEGIN cPanel-generated handler,do not edit
# Set the “ea-PHP74” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-PHP74 .PHP .PHP7 .phtml
</IfModule>


# PHP -- END cPanel-generated handler,do not edit
RewriteEngine On
#### PrintNinja unique redirects
RewriteCond %{HTTP_HOST} ^printninja.com$ [NC]    
RewriteRule ^learn/(.*) /printing-resource-center/ [NC,L,R=301]
RewriteRule ^digital-downloads/(.*) /printing-resource-center/ [NC,R=301]
RewriteRule ^resources/(.*) /printing-resource-center/ [NC,R=301]
RewriteRule ^pricing\/(.*)$ https://printninja.com/calculator/$1 [L]
#### Begin Uploader rewrites
# printingupload.com/files-submited/*   --redirect to ->   https://printninja.com/calculator/files-submited/*
RewriteCond %{HTTP_HOST} ^(www\.)?printingupload\.com$
RewriteRule ^printingupload\.com/files-submited\/(.*)$ https://printninja.com/calculator/files-submited/$1 [L]
# printingupload.com/invalid-order/*   --redirect to ->  https://printninja.com/calculator/invalid-order/*
RewriteCond %{HTTP_HOST} ^(www\.)?printingupload\.com$
RewriteRule ^printingupload\.com/invalid-order\/(.*)$ https://printninja.com/calculator/invalid-order/$1 [L]
# printingupload.com/*   --redirect to ->   https://printninja.com/calculator/products/upload_proofing/* (this rule must appear after the other printingupload.com/* rules)
RewriteCond %{HTTP_HOST} ^(www\.)?printingupload\.com$
RewriteRule ^printingupload\.com\/(.*)$ https://printninja.com/calculator/products/upload_proofing/$1 [L]
# submit.printingupload.com/*   --redirect to ->   https://printninja.com/calculator/submit_proofing/*
RewriteCond %{HTTP_HOST} ^submit\.printingupload\.com$
RewriteRule ^submit\.printingupload\.com\/(.*)$ http://printninja.com/calculator/submit_proofing/$1 [L]
# proofs.printingupload.com/approved/*   --redirect to ->   https://printninja.com/calculator/status/approved/*
RewriteCond %{HTTP_HOST} ^proofs\.printingupload\.com$
RewriteRule ^approved\/(.*)$ https://printninja.com/calculator/status/approved/$1 [L]
# proofs.printingupload.com/rejected/*   --redirect to ->   http://staging.printninja.com/calculator/status/rejected/*
RewriteCond %{HTTP_HOST} ^proofs\.printingupload\.com$
RewriteRule ^rejected\/(.*)$ https://printninja.com/calculator/status/rejected/$1 [L]
# proofs.printingupload.com/*   --redirect to ->   http://staging.printninja.com/calculator/rackfile/*

RewriteCond %{HTTP_HOST} ^proofs\.printingupload\.com$
RewriteRule ^(.*)$ https://printninja.com/calculator/rackfile/$1 [L]

解决方法

按照以下方式创建您的 htaccess 规则文件,请确保在测试您的 URL 之前清除浏览器缓存。

    # php -- BEGIN cPanel-generated handler,do not edit
# Set the “ea-php74” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>


# php -- END cPanel-generated handler,do not edit
RewriteEngine On
#### PrintNinja unique redirects
RewriteCond %{HTTP_HOST} ^proofs\.printingupload\.com$ [NC]
RewriteRule ^(.*)/?$ https://printninja.com/calculator/rackfile/$1 [R=301,NE,L]

RewriteCond %{HTTP_HOST} ^printninja.com$ [NC]    
RewriteRule ^learn/(.*) /printing-resource-center/ [NC,L,R=301]

RewriteRule ^digital-downloads/(.*) /printing-resource-center/ [NC,R=301]
RewriteRule ^resources/(.*) /printing-resource-center/ [NC,R=301]
RewriteRule ^pricing\/(.*)$ https://printninja.com/calculator/$1 [L]
#### Begin Uploader rewrites
# printingupload.com/files-submited/*   --redirect to ->   https://printninja.com/calculator/files-submited/*
RewriteCond %{HTTP_HOST} ^(www\.)?printingupload\.com$
RewriteRule ^printingupload\.com/files-submited\/(.*)$ https://printninja.com/calculator/files-submited/$1 [L]
# printingupload.com/invalid-order/*   --redirect to ->  https://printninja.com/calculator/invalid-order/*
RewriteCond %{HTTP_HOST} ^(www\.)?printingupload\.com$
RewriteRule ^printingupload\.com/invalid-order\/(.*)$ https://printninja.com/calculator/invalid-order/$1 [L]
# printingupload.com/*   --redirect to ->   https://printninja.com/calculator/products/upload_proofing/* (this rule must appear after the other printingupload.com/* rules)
RewriteCond %{HTTP_HOST} ^(www\.)?printingupload\.com$
RewriteRule ^printingupload\.com\/(.*)$ https://printninja.com/calculator/products/upload_proofing/$1 [L]
# submit.printingupload.com/*   --redirect to ->   https://printninja.com/calculator/submit_proofing/*
RewriteCond %{HTTP_HOST} ^submit\.printingupload\.com$
RewriteRule ^submit\.printingupload\.com\/(.*)$ http://printninja.com/calculator/submit_proofing/$1 [L]
# proofs.printingupload.com/approved/*   --redirect to ->   https://printninja.com/calculator/status/approved/*
RewriteCond %{HTTP_HOST} ^proofs\.printingupload\.com$
RewriteRule ^approved\/(.*)$ https://printninja.com/calculator/status/approved/$1 [L]
# proofs.printingupload.com/rejected/*   --redirect to ->   http://staging.printninja.com/calculator/status/rejected/*
RewriteCond %{HTTP_HOST} ^proofs\.printingupload\.com$
RewriteRule ^rejected\/(.*)$ https://printninja.com/calculator/status/rejected/$1 [L]
# proofs.printingupload.com/*   --redirect to ->   http://staging.printninja.com/calculator/rackfile/*

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。