Answer the question
In order to leave comments, you need to log in
Redirect to dynamic subdomain from folder?
Hello, about 7 o'clock in a complete stupor. Tried a bunch of google solutions from the search !!!!
There is a site like infoumnik.local/sub/user1 where sub and user1 are folders.
User1 contains index.php file
Trying to access user1 folder via user1.infoumnik.local subdomain via mode_rewrite
(SOLUTION BELOW)
Configured httpd.conf as follows:
<VirtualHost *:80>
DocumentRoot "c:/openserver/domains/infoumnik.local"
ServerName "infoumnik.local"
ServerAlias "infoumnik.local" "*.infoumnik.local"
ScriptAlias /cgi-bin/ "c:/openserver/domains/infoumnik.local/cgi-bin/"
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "c:/openserver/domains/infoumnik.local"
ServerName "infoumnik.local"
ServerAlias "infoumnik.local" "*.infoumnik.local"
ScriptAlias /cgi-bin/ "c:/openserver/domains/infoumnik.local/cgi-bin/"
SSLEngine on
SetEnvIf User-Agent ".*MSIE [1-5].*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
SetEnvIf User-Agent ".*MSIE [6-9].*" \
ssl-unclean-shutdown
</VirtualHost>
127.0.0.1 infoumnik.local
127.0.0.1 user1..infoumnik.local
127.0.0.1 user2.infoumnik.local
127.0.0.1 user3.infoumnik.local
AddDefaultCharset off
# Устанавливаем страницу для ошибки 404
ErrorDocument 404 /index.php
# Устанавливаем индексный файл для директории
DirectoryIndex index.php
# Определяем правила для модуля mod_rewrite
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.infoumnik\.local$
RewriteCond %{HTTP_HOST} (www\.)?(.*)\.infoumnik\.local$
RewriteCond %{REQUEST_URI} !sub/
RewriteRule ^(.*)$ sub/%2/$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
Answer the question
In order to leave comments, you need to log in
VirtualDocumentRoot /var/www/user/data/www/%0
implements automatic selection for a site of a directory like
/var/www/user/data/here_full_site_name
This is from the virthost config in Apache.
Look at the examples in the documentation, it may help in your desires.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question