R
R
rumkin2011-05-29 21:51:13
Domain Name System
rumkin, 2011-05-29 21:51:13

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

9 answer(s)
S
Sergey Savostin, 2011-05-29
@savostin

RewriteCond %{HTTP_HOST} ^(.+)\.([0-9]+)\.dev$
RewriteRule ^(.*)$ /var/www/dev/%2/%1/$1 [E=VIRTUAL_HOST: ${HTTP_HOST},L]

Z
zloyshaman, 2011-05-29
@zloyshaman

Write once .dev in hosts. And then resolve everything through mod_rewrite or whatever else you have on Apache.

T
tzlom, 2011-05-29
@tzlom

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]

X
xRay, 2011-05-29
@xRay

Here is a more or less recipe, there is an analogue of Denver automatic virtual hosts for Linux

A
Alexey Pomogaev, 2011-05-30
@Foror

server-tuning.info/nginx/auto-subdomains.html - here's how it's done on nginx

J
Jazzist, 2011-05-31
@Jazzist

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

J
Jazzist, 2011-05-31
@Jazzist

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.

J
Jazzist, 2011-05-31
@Jazzist

>automatically redirect all *.2011.dev requests to a folder with directories Sub-question
- why don't you like site.localhost?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question