Welcome Guest, Not a member yet? Register   Sign In
automatic creation of sub-domains
#1

[eluser]stalkerok[/eluser]
Apache host conf

httpd-vhosts.conf
Code:
<VirtualHost *:80>
    DocumentRoot /WebServers/www/test
    ServerName test.ru
    ServerAlias *.test.ru
    ErrorLog "/WebServers/Apache/logs/test_error_log"
    CustomLog "/WebServers/Apache/logs/test_access_log" common
</VirtualHost>

.htaccess
Code:
AddDefaultCharset utf-8
Options -Indexes
Options +FollowSymLinks
Options -MultiViews
DirectoryIndex index.php
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    RewriteCond %{HTTP_HOST} ^(.+)\.test\.ru$ [NC]
    RewriteCond %{HTTP_HOST} !^www\.test\.ru$ [NC]
    RewriteCond %{REQUEST_URI} !^/sub
    RewriteRule ^(.*) %{HTTP_HOST}$1
    RewriteRule ^(.*)\.test\.ru(.*) /sub/$1$2
    RewriteRule ^sub\.(.*) /sub/$1

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|/assets/|robots\.txt|favicon\.ico)
    RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]

</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 index.php
</IfModule>

I want to customize

test.ru/sub/whatever_name

to automatically create

whatever_name.test.ru

but there is an error

Quote:Forbidden

You don't have permission to access /index.php//sub/indexindex.php/sub/indexindex.php/sub/indexindex.php/sub/indexindex.php/sub/indexindex.php/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php/sub/indexindex.php

.........
/sub/indexindex.php/sub/index/sub/index/sub/index/sub/indexindex.php on this server.
#2

[eluser]smilie[/eluser]
You will need to know a bit more about apache (maybe you already know), but;

I would suggest to change apache config to include another (virtual host) directory, let's say:

/var/www/virtual_hosts/*

then, give read / write privileges to that directory to your PHP / Apache group and store all virtual host files in there.

Also suggest to use either suphp or sudo to allow PHP / Apache to restart (and only graceful restart!) of apache itself.

This should be working.
#3

[eluser]stalkerok[/eluser]
I do

ServerAlias ​​*. test.ru

to redirect all subdomains (whatever_name.test.ru) on test.ru/sub/whatever_name

but does not work
#4

[eluser]Bart v B[/eluser]
if you give me some time, then i will share my solution for this. Smile
I am working on a hosting controlpanel that works with some shell scripting.

It's a very bad practice to give php su or sudo rights.
So my idea for that is very simple, i let php create a simple textfile, and let the server do the rest.
I hope that you have a linux server, and if so, what kind of distro are you using?
#5

[eluser]stalkerok[/eluser]
Thanks, I use Ubuntu
#6

[eluser]Enviromed[/eluser]
We are very interested in your solution. We use Ubuntu as well.

Please post this over at expressionengine.stackexchange.com.


There are some top veteran ee / php devs over there, quick collaborative responses and there's a crunch right now to increase posts to get out of stackexchange beta. If we get some answers, I'll post the link back.







Theme © iAndrew 2016 - Forum software by © MyBB