基于htaccess的子域重定向到主域中的文件夹

时间:2018-05-03 10:46:36

标签: .htaccess redirect dns subdomain

我的htaccess文件有问题。

我的主域kielkowski-szkolka.pl指向根文件夹 /kielkowski-szkolka.pl/public_html 现在,我创建了子域automatyka.kielkowski-szkolka.pl,其点数为/kielkowski-szkolka.pl/public_html/automatyka

现在,当我尝试转到automatyka.kielkowski-szkolka.pl时,它会将我重定向到我的主域/

kielkowski-szkolka.pl

您可以查看我的根htaccess并告诉我要添加/更改的内容以使其正常工作吗?

SetEnv PHP_VER 5
php_flag apc.enabled On
php_flag apc.cache_by_default On
php_value session.gc_maxlifetime 86400
php_value session.cookie_lifetime 86400
Options +FollowSymLinks
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

#przekierowanie z http na https i z ww na bez www
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^kielkowski-szkolka.pl [NC]
RewriteRule ^(.*)$ https://kielkowski-szkolka.pl%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTPS} !^on$
RewriteRule ^(.*)$ https://kielkowski-szkolka.pl/$1 [R=301,L]
# Redirect non-existing files or folders to index
# Redirect non-existing files or folders to index
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ / [L,QSA,R=301]
</IfModule>

1 个答案:

答案 0 :(得分:2)

您可以检查您的子域名,然后重定向到这样的文件夹,例如。

RewriteCond %{HTTP_HOST} ^automatyka\.kielkowski-szkolka\.pl$
RewriteRule ^(.*)$ http://kielkowski-szkolka.pl/automatyka/$1 [L,R=301]