说,我有一个域http://www.example.com
。我在 httpd.conf :DocumentRoot "/Apache22/htdocs"
中有这个。
我还有/Apache22/htdocs/dir1
应用程序目录,我想强制用户使用https
与https://www.example.com/dir1
进行连接,例如,使用网址:http
并将任何https
请求重定向到此目录的NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /Apache22/htdocs/
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com/dir1
DocumentRoot /Apache22/htdocs/dir1
Redirect permanent /dir1 https://www.example.com/dir1
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
ServerName www.example.com/dir1
DocumentRoot /Apache22/htdocs/dir1
SSLEngine on
SSLCertificateFile conf/ssl/server.cert
SSLCertificateKeyFile conf/ssl/server.key
</VirtualHost>
。
我尝试了 VirtualHost 和重定向,所以:
https
但显然Apache忽略 ServerName 中的所有子目录,因此 www.example.com 和 www.example.com/dir1 都是同样在 VirtualHost 块中,就Apache而言。
如何实现访问 dir1 的任何网址的(.*?) # Data before sentences (to be removed)
( # Capture Both sentences and text in between
H.*?e.*?l.*?l.*?o.*?\s # Hello[space]
(<.*?>)* # Optional Opening Tag(s)
進.*?撃.*?の.*?巨.*?人.*? # 進撃の巨人
(<\/.*?>)* # Optional Closing Tag(s)
(.*?) # Optional Data in between sentences
(<.*?>)* # Optional Opening Tag(s)
L.*?o.*?r.*?e.*?m.*?\s # Lorem[space]
(<.*?>)* # Optional Opening Tag(s)
i.*?p.*?s.*?u.*?m.*? # ipsum
)
(.*) # Data after sentences (to be removed)
重定向?
答案 0 :(得分:0)
尝试:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /Apache22/htdocs/
Redirect permanent /dir1 https://www.example.com/dir1
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
ServerName www.example.com
DocumentRoot /Apache22/htdocs
SSLEngine on
SSLCertificateFile conf/ssl/server.cert
SSLCertificateKeyFile conf/ssl/server.key
</VirtualHost>
ServerName
指令采用主机名,而不包括路径组件。