mod_rewrite Print

  • 0

This will let us change url to user name. The url carry a (username=user1) information.

http://domain.com/user1/ --> http://domain.com/customers/index.php?username=user1

RewriteRule ^([^/]+)/?$ customers/index.php?username=$1

========================

For this is
http://subdomain.netvic.net --> http://netvic.net/customer/index.php?username=subdomain

RewriteEngine On

Rewritecond %{HTTP_HOST} !^(www|ftp|mail). [NC]
RewriteCond %{HTTP_HOST} ^([^.]+).netvic.net$ [NC]
RewriteRule .*
http://netvic.net/customers/index.php?username=%1 [R,L]

=====================

For this will do the same as above but it carry the original URL.

RewriteEngine On
RewriteRule ^(customer|index).php$ - [QSA,L]
RewriteCond %{HTTP_HOST} !^(www|ftp|mail). [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9]+).telesmi.com$ [NC]
RewriteRule !^customers/index.php$ /customers/index.php?username=%1 [L]

Was this answer helpful?

« Back