1
我用来让用户访问domain.com/dashboard,但现在希望它们转到dashboard.domain.com。一些用户仍然在使用旧地址,并得到一个非工作/非常丑陋的页面。即使文件夹名称本身是仪表板(public_html/dashboard),是否可以将子文件夹(domain.com/dashboard)重定向到子域(dashboard.domain.com),还是仅仅是更容易更改子文件夹的名称有所不同?这是我目前在public_html的.htaccess文件中所拥有的。将文件夹重定向到同名的子域名
RewriteCond %{HTTP_HOST} ^dashboard.domain.com$
RewriteCond %{REQUEST_URI} !^/dashboard/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ /dashboard/$1
RewriteCond %{HTTP_HOST} ^dashboard.domain.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(/)?$ dashboard/index.php [L]
不幸的是,没有工作。我删除了public_html/.htaccess文件中的仪表板参考,然后将代码放在public_html/dashboard/.htaccess文件中,当我转到dashboard.domain.com时,它只是加载public_html/index.php页面,当我访问domain.com/dashboard时,它会加载,但是以现在它所做的丑陋/错误链接的方式加载。 –
当您打开'domain.com/dashboard /'时,是否不会重定向到'dashboard.domain.com'? – anubhava
不,它只是加载public_html /仪表板/ index.php URL为domain.com/dashboard –