htaccess domain.com/sub to sub.domain.com



我想要的:example.com/sub为sub.example.com/我创建了一个子域,主域除URL以外没有提供其他帮助来生成HTACCESS文件。它具有2个值"子域"one_answers"文件夹"。

在子域中,我写了" https://example.com/sub",在文件夹中我写了foldername:" sub"。

它给了我这对我不起作用。我在做什么错?

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} https://example.com/sub
RewriteCond %{REQUEST_URI} !sub/
RewriteCond %{REQUEST_URI} !/.well-known/acme-challenge/
RewriteRule ^(.*)$ sub/$1 [L]

您需要从%{HTTP_HOST}条件中删除URL方案。并且您的RewriteCond %{HTTP_HOST} https://example.com/sub条件应为RewriteCond %{HTTP_HOST} ^example.com$

尝试

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com$
RewriteCond %{REQUEST_URI} !sub/
RewriteCond %{REQUEST_URI} !/.well-known/acme-challenge/
RewriteRule ^(.*)$ /sub/$1 [L]

让我知道它如何为您工作。

最新更新