简体   繁体   English

如何使用 htaccess 重定向链接?

[英]How to redirect a link using htaccess?

I have two domains as follows:我有两个域如下:

  1. http://www.sysmedac.com/ http://www.sysmedac.com/

  2. https://www.sysmedacmicrosoft.com/Index.html . https://www.sysmedacmicrosoft.com/Index.html

How do I redirect from the first domain to the second one using htacces?如何使用 htaccess 从第一个域重定向到第二个域? Have used the following code:已经使用了以下代码:

<IfModule>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^http://www.sysmedac.com/$
    RewriteRule ^(.*) https://www.sysmedacmicrosoft.com/Index.html#!/$1 [R=301,L]
    Redirect 301 /contact https://www.sysmedacmicrosoft.com/#!/Contact
</IfModule>

But it doesn't work.但它不起作用。

you can use-您可以使用-

RewriteEngine On
Redirect 301 https://www.old_url.com http://www.new_url.com/
#===========
Redirect 301 https://www.sysmedacmicrosoft.com/Index.html http://www.sysmedac.com/

or if you want to remove index.html-或者如果你想删除 index.html-

<IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.html [QSA,L]
</IfModule>

You need to write below rule to Redirect from an index.html file to the main link.您需要编写以下规则以从 index.html 文件重定向到主链接。

Redirect /index.html /重定向/index.html/

This rule will redirect your http://www.sysmedac.com/index.html to http://www.sysmedac.com/ .此规则会将您的http://www.sysmedac.com/index.html重定向到http://www.sysmedac.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM