的.htaccess并重写子域名重写、域名、htaccess

2023-09-02 00:57:06 作者:踏雪寻梅

我有一个自定义的框架运行一个网站。不过,我想增加一个网关子域来处理特定的请求。除了作为一个子域的API来处理API请求。

I have a website that runs on a custom framework. However i would like to add a gateway subdomain to handle specific requests. As well as a api subdomain to handle api requests.

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

Now is have a complex folder structure:

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

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

Now i would like to get the http://gateway.example.com to redirect to subs > gateway and the http://api.example.com to subs > api folders.

第一的.htaccess [1]

The first .htaccess [1]

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

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

The second .htaccess [2] (i don't think this needed to post here, but you newer know ;)

<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]。但是,为了什么呢?

I think i should change the first .htaccess [1]. But to what?

请帮助我。

推荐答案

这可以固定设置你的 VirtulDomain 正确像这样网​​关子域名:

This can be fixed by setting up your VirtulDomain correctly like this for gateway sub domain:

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