I want to redirect a subdirectory to a subdomain either using .htaccess or cpanel
redirects from
domain.in/subfolder
to
subfolder.domain.in
im using cakephp app for both domain.in and subfolder.domain.in
each have separate core library
Please help me to solve this
Thanks in advance
You can use this rule as very first rule in your /subfolder/.htaccess
file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.in$ [NC]
RewriteRule (.*) http://subfolder.domain.in/$1 [NE,R=302,L]
Or else:
RewriteCond %{HTTP_HOST} ^(?:www\.)?(domain\.in)$ [NC]
RewriteRule (.*) http://subfolder.%1/$1 [NE,R=302,L]
Using the following .htaccess file might work:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain.in [NC]
RewriteRule ^(.*)$ http://www.domain.in$1 [L,R=301]
RedirectMatch 301 ^/subfolder/(.*)$ http://subfolder.domain.in/$1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.