简体   繁体   English

正在将网站重定向到手机…文件名?

[英]redirecting site to mobile…file name?

This is my first time creating a mobile site for someone I have the javascript code all set up and when tested on my phone, it redirects it to: m.websitename.com, like I want it to. 这是我第一次为所有已经设置好javascript代码的人创建一个移动网站,并且在我的手机上对其进行测试时,它会将其重定向到:m.websitename.com,就像我想要的那样。 However, I have no idea what to name the file I am wanting it to redirect to? 但是,我不知道要重定向到的文件的名称是什么? I saved the file under: mobile.html, but it isn't redirecting to it. 我将文件保存在以下位置:mobile.html,但未重定向到该文件。

I don't want it to redirect saying www.websitename.com/mobile, I don't think it looks as professional. 我不希望它重定向说www.websitename.com/mobile,我认为它看起来并不专业。

Thanks 谢谢

index.html or default.html is the convention. index.htmldefault.html是约定。 so why not direct to 那么为什么不直接

m.websitename.com/index.html

and configure the subdomain so that m.websitename.com is actually pointing to websitename.com/m folder. 并配置子域,以使m.websitename.com实际上指向websitename.com/m文件夹。 so that folder can have its own index file. 这样该文件夹可以拥有自己的索引文件。

You would probably want to do this using subdomain and destination setup from your server you are using (Most of webhosting companies made this easy through their software eg cPanel). 您可能希望使用正在使用的服务器中的子域和目标设置来执行此操作(大多数网络托管公司通过其软件(例如cPanel)简化了此操作)。 Directory structures is going to look like this. 目录结构看起来像这样。 So when user was redirected t m.yourweb.com/ then it's not going to have m.yourweb.com/mobie. 因此,当用户重定向到m.yourweb.com/时,它将不再具有m.yourweb.com/mobie。

domain [directory]
      css [directory]
      js  [directory]
      index.jsp  [file]
      purchase.jsp  [file]
      ...

      subdomain [directory] <- for mobile
        css [directory]
        js  [directory]
        index.jsp  [file]
        purchase.jsp  [file]

So when mobile user was detected, JS is going to redirect this user to the subdomain (for mobile) instead of normal directory. 因此,当检测到移动用户时,JS会将其重定向到子域(用于移动设备)而不是普通目录。 The other recommendation (which is better I think) is use the same logic from the above but when user was redirected to m.yourweb.com/ load css file for mobile version web instead of normal web. 另一个建议(我认为更好)是使用与上述相同的逻辑,但是当用户重定向到m.yourweb.com/时,请为移动版本Web而不是普通Web加载css文件。 loading css through JS 通过JS加载CSS

If you think this is complicated, you might be interested in having a look at CSS3 media queries . 如果您认为这很复杂,则可能会对CSS3媒体查询感兴趣。 This basically changes CSS layout depending on current users' screen. 这基本上会根据当前用户的屏幕更改CSS布局。 resolution Media queries tutorial 分辨率媒体查询教程

You can have any filename you like. 您可以拥有任何喜欢的文件名。 But as btevfik mentioned either put index.html or default.html 但是正如btevfik所提到的,要么放置index.html要么default.html

I recommend index.html 我推荐index.html

Also you can set the default file in you server configuration. 您也可以在服务器配置中设置默认文件。 By default most servers have the default file handler as index.html. 默认情况下,大多数服务器的默认文件处理程序为index.html。 For Apache it will be either index.html or index.php. 对于Apache,它将是index.html或index.php。 You can change this to something like mobile-handler.html by changing the server configuration. 您可以通过更改服务器配置将其更改为mobile-handler.html之类的内容。

So whenever you access your site by http://your-site.com or m.your-site.com the default file specified in the server configuration is loaded. 因此,无论何时通过http://your-site.com或m.your-site.com访问站点,都会加载服务器配置中指定的默认文件。

Please note that your-site.com and m.your-site.com will have different site root, hence request will be handled by difffernt files. 请注意,your-site.com和m.your-site.com将具有不同的站点根目录,因此请求将由不同文件处理。

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

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