wordpress子域名导致主域名

问题描述 投票:0回答:1

基本上,我想在url中的某个位置添加一个用户,以便以后可以获取它并尝试使用子域方法:

mike.domain.com  -load- domain.com
nik1233.domain.com/about -load- domain.com/about etc

[请注意,我希望URL保持原样(以便我可以通过javascript命名),而wordpress似乎已经剥离了www并添加了https,而我在根目录的htaccess文件中没有看到任何内容。

到目前为止,我所管理的唯一事情是在cpanel中设置通配符子域并输入htaccess中的内容

RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/%{REQUEST_URI} [R=301,L]

可以,但是显示了未验证的证书错误。

近5天后仍然没有弄清楚,即使我应该放弃user.domain.com并可能选择domain.com/user吗?

wordpress .htaccess subdomain
1个回答
0
投票

您可以在htaccess根目录中使用以下代码。

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(^.*)\.xyz.com
RewriteRule (.*)  index.php?username=%1&$1  [L,QSA]

http://hello.xyz.com/abc/?var=12

Array
(
    [username] => abc
    [index_php] => 
    [abc/] => 
    [var] => 12
)

通配符子域是激活DNS所必需的。您将在查询字符串中获得用户名,您可以在代码内使用该用户名。

© www.soinside.com 2019 - 2024. All rights reserved.