简体   繁体   中英

point subdomain to subfolder htaccess

I want to create new subdomain for mobile site. so i want to point this domain to subfolder in root folder in my server:

Example: www.mywebsite.com point to www folder

I will create sub folder inside wwww name it: mobile_version I will create subdomain for mobile name it: m.mywebsite.com I want to point m.mywebsite.com to mobile_version folder NOT REDIRECT

if someone open mywebsite from mobile then will redirect to m.mywebsite.com and show the index.php inside mobile_version without redirect to m.mywebsite.com/mobile-version

I hope I passed my issue.

what I did in htaccess:

RewriteCond %{HTTP_HOST} !^m.jeelplus.com$
RewriteRule ^(.*)$ http://m.jeelplus.com/mobile_version/$1 [R=301,L]

if m.jeelplus.com is going to map to the sub-directory, then why are you passing the sub-directory as a URI parameter? Also if you want it to re-map, NOT redirect then you can't have [R=301] because this is a redirect...

Your application also needs to determine whether the user is coming from mobile or not, and redirect to your m.jeelplus.com this can't really be done through .htaccess

your .htaccess will literally redirect every request into the server that isn't m.jeelplus.com to m.jeelplus.com/mobile_version/ this is probably not what you actually want to do..

I assume you want to rewrite anything coming into m.jeelplus.com to use /mobile_version/index.php

in which case try something more like:

RewriteCond ${HTTP_HOST} ^m.jeelplus.com$
RewriteRule ^(.*)$ mobile_version/index.php/$1 [L]

Alternative setup a new vhost with its document root pointed to the mobile version folder with the ServerName m.jeelplus.com and use the normal remap .htaccess...

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM