doulao7572
2018-01-31 07:46
浏览 62
已采纳

如何使用htaccess将路径重定向到子域

I'm new to htaccess, need help regarding redirection a path to subdomain path.

My subdomain is

Subdomain :  https://abc.example.com/

which is pointing to path

Path :  https://example.com/folder1/abc

Now I want if someone is accessing directory using path it should redirect to the subdomain

Request :  https://example.com/folder1/abc/folder2/file
Redirect : https://abc.example.com/folder2/file

I searched a lot but not able to proceed. Any kind of help will be appreciated.

Complete my htaccess file

RewriteEngine on

RewriteCond %{HTTP_HOST} !^api\. [NC]
RewriteRule .* https://api.example.com/$0 [L,NE,R=301]

ErrorDocument 403     /error-pages/403.php
ErrorDocument 404     /error-pages/404.php

图片转代码服务由CSDN问答提供 功能建议

我是htaccess的新手,需要有关重定向子域路径路径的帮助。 \ n

我的子域是

 子域名:https://abc.example.com/
   
 
 

指向路径

 路径:https://example.com/folder1/abc
nn

现在 我想如果有人使用路径访问目录,它应该重定向到子域

 请求:https://example.com/folder1/abc/folder2/file
Redirect:https  ://abc.example.com/folder2/file 
   
 
 

我搜索了很多但无法继续。 任何类型的帮助将不胜感激。

完成我的htaccess文件

  RewriteEngine on 
 
RewriteCond%{HTTP_HOST}!^ api  \。  [NC] 
RewriteRule。* https://api.example.com/$0 [L,NE,R = 301] 
 
ErrorDocument 403 /error-pages/403.php
ErrorDocument 404 / error-pages / 404。  php 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • doudan5136 2018-01-31 07:57
    最佳回答

    Inside folder1/abc/.htaccess keep this rule as your first rule:

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^abc\. [NC]
    RewriteRule .* http://abc.example.com/$0 [L,NE,R=301]
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题