Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 子域映射到子目录_Php_.htaccess_Virtualhost_Mod Proxy_Mod Proxy Html - Fatal编程技术网

Php 子域映射到子目录

Php 子域映射到子目录,php,.htaccess,virtualhost,mod-proxy,mod-proxy-html,Php,.htaccess,Virtualhost,Mod Proxy,Mod Proxy Html,我有一个web应用程序,它需要为每个公司提供动态子域。该站点也有SSL。我在Ubuntu VPS上使用apache。我所做的是做了如下的虚拟主机设置 <VirtualHost *:80> ServerName domain.com ServerAlias *.domain.com Redirect permanent / https://domain.com/ </VirtualHost> <VirtualHost *:443>

我有一个web应用程序,它需要为每个公司提供动态子域。该站点也有SSL。我在Ubuntu VPS上使用apache。我所做的是做了如下的虚拟主机设置

<VirtualHost *:80>
    ServerName domain.com
    ServerAlias *.domain.com
    Redirect permanent / https://domain.com/
</VirtualHost>
<VirtualHost *:443>
    ServerName domain.com
    ServerAlias *.domain.com
    ..........
    .................
</VirtualHost>
当我访问“”时,会将其重定向到“”。我知道为什么会发生这种情况,因为当htaccess重定向发生在“”时,我的virtualhost配置会看到一个非SSL请求,并将该请求重定向到与SSL相同的地址。所以我改变了对这个的.htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ https://domain.com/app/$1 [P,NC,QSA]
我在重写规则中加入了“https”。当我再次访问“”时,它给了我这个错误

Internal Server Error

The server encountered an internal error or misconfiguration and was     
unable to complete your request.

Please contact the server administrator at webmaster@localhost to 
inform them of the time this error occurred, and the actions you 
performed just before this error.

More information about this error may be available in the server error 
log.

Apache/2.4.7 (Ubuntu) Server at kjdcndkj.domain.com Port 443
最后我想要的是

1) redirect any Non-SSL trafic to SSL
2) any *.domain.com to /app folder
有人能帮我吗

谢谢。

试试这个:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} ^([a-z0-9-]+)\.domain\.com [NC] 
RewriteRule ^(.*)$ %1/$1 [L]
试试这个:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} ^([a-z0-9-]+)\.domain\.com [NC] 
RewriteRule ^(.*)$ %1/$1 [L]

有人能帮我吗请:)有人能帮我吗请:)没有,文件夹应该始终是/app,所以我会把它放在RewriteCond%{HTTPS}上并检查RewriteEngine=在重写规则^https://%{HTTP\u HOST}%{REQUEST\u URI}[L,R=301]RewriteCond%{HTTP\u HOST}^([a-z0-9-]+)\.domain\.com[NC]RewriteRule^(.*)$app/$1[L]否该文件夹应始终为/app,因此我会将其置于RewriteCond%{https}上并检查RewriteEngine=在重写规则^https://%{HTTP\u HOST}%{REQUEST\u URI}[L,R=301]重写cond%{HTTP\u HOST}^([a-z0-9-]+)\.domain\.com[NC]重写规则^(.*)$app/$1[L]