简体   繁体   中英

.htaccess and rewrite sub domains

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]

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.

The first .htaccess [1]

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

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>

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

Please help me out.

可以通过为gateway子域正确设置VirtulDomain来解决此问题:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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