-->

htaccess的和重写子域(.htaccess and rewrite sub domains)

2019-10-19 05:31发布

我有一个自定义的框架中运行一个网站。 但是我想补充一个网关子域来处理特定的请求。 除了作为一个API子域来处理API请求。

现在是有一个复杂的文件夹结构:

-application
-config
-subs (subdomain folder)
  - gateway
  - api
-library
-public
  .htaccess [2]
-scripts
-tmp
.htaccess [1]

现在我想获得http://gateway.example.com重定向到潜艇>网关和http://api.example.com到潜艇> API文件夹。

第一htaccess的[1]

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/scripts/
    RewriteRule ^(.*)$ /public/$1 [L]
 </IfModule>

第二的.htaccess [2](我不认为这需要张贴在这里,但你知道新)

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^popup/   - [L]
RewriteRule ^img/   - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$              index.php?url=$0 [PT,L]
</IfModule>

我想我应该改变第一的.htaccess [1]。 但是什么?

请帮助我。

Answer 1:

这可以通过固定设置您的VirtulDomain为正确喜欢这个gateway子域名:

DocumentRoot /home/example/domains/example.com/public_html/subs/gateway


文章来源: .htaccess and rewrite sub domains