Answer the question
In order to leave comments, you need to log in
Hosts and folder organization for development
Dear audience. I develop projects in php, many different ones, I test different CMS, I write my own whales. For access, I like to use domains instead of nested folders, for example project-name.2011.dev , but every time I get fed up with registering hosts in host and apache.conf (there are about 40 projects in folders) and they are constantly being added. Attention question. Which way to dig / What mana to smoke to automatically redirect all requests like *.2011.dev to a folder with directories like .../dev/2011/*?
I am using Linux.
Answer the question
In order to leave comments, you need to log in
RewriteCond %{HTTP_HOST} ^(.+)\.([0-9]+)\.dev$
RewriteRule ^(.*)$ /var/www/dev/%2/%1/$1 [E=VIRTUAL_HOST: ${HTTP_HOST},L]
Write once .dev in hosts. And then resolve everything through mod_rewrite or whatever else you have on Apache.
in hosts you will have to register all your subdomains, well, or raise a local DNS,
make a vhost and assign ServerAlias *.upyachka.ru to it, direct it to the project
folder in the folder, place something similar to
well, just replace the subdomain name with a grouping, and in the substitution it will also
be something very close to what you want
RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^probe\.testpage\.local$
RewriteRule ^(.+) %{HTTP_HOST}$1
RewriteRule ^probe\.testpage\.local(.*)$ /probe%{REQUEST_URI} [L]
Here is a more or less recipe, there is an analogue of Denver automatic virtual hosts for Linux
server-tuning.info/nginx/auto-subdomains.html - here's how it's done on nginx
1. Use the panel
2. I don’t want to use the panel, so I wrote a tool for this routine - whitepiano.ru/info/domains
And one more smart idea came about this - to write or find a plugin for the IDE so that when creating a project, it adds a virthost entry.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question