w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Use htaccess to redirect subdomain to a directory

You can use mod_rewrite for this:

RewriteCond %{HTTP_HOST} ^shop.
RewriteRule (.*) http://www.domain.com/shop/$1 [R=301,L]

The RewriteCond checks to make sure that the hostname of the request begins with the string "shop." and if so, the subsequent RewriteRule is evaluated.

The ^ before shop ensures that it only matches the string "shop" if it is at the beginning of the hostname.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.