【发布时间】:2018-06-05 04:41:58
【问题描述】:
我有一个 example.com,我在 Cpanel 中为它创建了一个子域。在 Cpanel 中出现:
test.domain.com /public_html/test 未重定向 我想访问我的新子域:test.domain.com 我在子域文件夹中创建了一个 index.html:/home/domainname/public_html/test
我的 .htaccess 是:
AddType text/x-component .htc
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
RedirectMatch 301 ^/test/(.*)$ http://test.example.com/$1
RewriteRule ^(en|fr)/([a-z]*) /index.php
RewriteRule !\.
(js|ico|gif|jpg|jpeg|png|css|swf|htm|xml|php|map|ttf|woff|woff2)$
index.php
RewriteRule ^(form|ajax|captcha)/([a-z]*) /index.php
domain.com 有 ssl,而子域我没有。我在 .htaccess 中为子域添加了这一行:
RedirectMatch 301 ^/test/(.*)$ http://test.example.com/$1
但不工作:访问 test.example.com 时,我得到 “此页面不工作 test.example.com 将您重定向了太多次。”
如果与 https 一起使用:
RedirectMatch 301 ^/test/(.*)$ https://test.example.com/$1
我当然会收到 ssl 警告和 未找到 在此服务器上找不到请求的 URL /home/domainname/public_html/index.php。
我做错了什么?
【问题讨论】:
-
如果我评论 htaccess 它在子域中工作(它向我显示 html 页面)但域站点无法正常工作
标签: php .htaccess redirect cpanel