Apache
Dynamic username as subdomain system with .htaccess
Feb 8th
Create an .htaccess file with the following code to build a dynamic username as subdomain.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.mydomain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?username=%1 [L]
All visits to http://username.mydomain.com will redirect to index.php?username=subdomain. You can then assign that username to a cookie and build the user’s web page.
Follow me on Twitter
.htaccess para redireccionar un dominio a otro
Oct 4th
Click here to translate this post
Si quieres que Apache redireccione la ruta de un dominio a otro utiliza el siguiente código en un archivo .htaccess:
RedirectMatch permanent (.*) http://dominio2.com$1
Este archivo tiene que estar en la raíz del DocumentRoot del dominio.
Gracias a este código, si por ejemplo un usuario accede a http://dominio1.com/carpeta1/test.php, automáticamente será redireccionado a http://dominio2.com/carpeta1/test.php
Follow me on Twitter