简体   繁体   English

将子域指向子文件夹htaccess

[英]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 示例:www.mywebsite.com指向www文件夹

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 我将在wwww内创建子文件夹,将其命名为:mobile_version我将为手机创建子域,将其命名为:m.mywebsite.com我想将m.mywebsite.com指向mobile_version文件夹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 如果有人从手机打开mywebsite,则将重定向到m.mywebsite.com并在mobile_version中显示index.php而不重定向到m.mywebsite.com/mobile-version

I hope I passed my issue. 我希望我能通过我的问题。

what I did in htaccess: 我在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? 如果m.jeelplus.com将要映射到子目录,那么为什么要将该子目录作为URI参数传递? Also if you want it to re-map, NOT redirect then you can't have [R=301] because this is a redirect... 另外,如果您希望它重新映射,不进行重定向,那么您就无法使用[R = 301],因为这是重定向...

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 您的应用程序还需要确定用户是否来自移动设备,然后重定向到您的m.jeelplus.com这实际上无法通过.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.. 您的.htaccess实际上会将每个不是m.jeelplus.com请求都重定向到服务器,该请求将直接重定向到m.jeelplus.com/mobile_version/

I assume you want to rewrite anything coming into m.jeelplus.com to use /mobile_version/index.php 我假设您想重写进入m.jeelplus.com以使用/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... 另一种方法是,设置新的虚拟主机,其文档根目录指向具有ServerName m.jeelplus.com的移动版本文件夹,并使用常规的remap .htaccess ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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