Подскажите как сделать так, чтобы при заходе по адресу http://site.com/sub или http://www.site.com/sub переадресовывало на http://sub.site.com?
В корневом каталоге располагается файл .htaccess с содержимым
Options -Indexes Options +FollowSymLinks RewriteEngine On RewriteBase / ErrorDocument 400 /index.php?route=error/_400 ErrorDocument 401 /index.php?route=error/_401 ErrorDocument 403 /index.php?route=error/_403 ErrorDocument 404 /index.php?route=error/_404 ErrorDocument 500 /index.php?route=error/_500 RewriteCond %{HTTP_HOST} ^site\.com$ RewriteRule ^sub/(.*)$ http://sub.site.com/$1 [L,R=301] RewriteRule ^sub$ http://sub.site.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?route=$1 [L,QSA]
В папке sub располагается файл .htaccess с похожим содержимым
Options -Indexes Options +FollowSymLinks RewriteEngine On RewriteBase / ErrorDocument 400 /index.php?route=error/_400 ErrorDocument 401 /index.php?route=error/_401 ErrorDocument 403 /index.php?route=error/_403 ErrorDocument 404 /index.php?route=error/_404 ErrorDocument 500 /index.php?route=error/_500 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
Так же имеется вопрос, можно ли как то из папки sub в файле .htaccess обратиться к файлу из корневой директории, например, RewriteRule ^style/([@.A-Za-z0-9-/+_=]+)$ ../library/styles/$1 [L] ?
Пытаюсь сделать следующее
Options -Indexes Options +FollowSymLinks RewriteEngine On RewriteBase / ErrorDocument 400 /index.php?route=error/_400 ErrorDocument 401 /index.php?route=error/_401 ErrorDocument 403 /index.php?route=error/_403 ErrorDocument 404 /index.php?route=error/_404 ErrorDocument 500 /index.php?route=error/_500 # RewriteCond %{ENV:REDIRECT_VHOST} ^$ RewriteCond %{HTTP_HOST} ^(www\.)?sub\.site\.com$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ sub/index.php?route=$1 [L,E=VHOST:1] # RewriteCond %{HTTP_HOST} ^site\.com$ #RewriteRule ^sub/(.*)$ http://sub.site.com/$1 [L,R=301] #RewriteRule ^sub$ http://sub.site.com/$1 [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
Не работает перенаправление с site.con/sub на sub.site.com (циклическая переадресация), а так же при переходе, например, на sub.site.com/abc - ошибка 500, кто знает, что нужно исправить?