从子域子目录路径htaccess的内部重写 [英] htaccess internal rewrite from subdomain to subdir path

查看:124
本文介绍了从子域子目录路径htaccess的内部重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林在至少24小时忙碌在这个问题上,我似乎无法获得此脚本工作。该脚本犯规重定向的。

Im at least 24 hours busy on this subject, I cant seem to get this script to work. The script doesnt redirect at all.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^m\.skynet\.com$
RewriteRule ^/(.*)$ /mobile/final/$1 [L,NC]

我是什么做错了吗?

What am I doing wrong?

更新:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^m\.skynet\.com$
RewriteCond %{REQUEST_URI} !^/mobile/final/
RewriteRule ^(.*)$ /mobile/final/$1 [L,NC]

这部分的工作,但像m.skynet.com \环节的download.php不会被重定向

This partially works, but links like m.skynet.com\download.php wont get redirected

更新:45分钟后

现在突然的作品。 但是,URL重写获取在FireFox,而在Chrome浏览器能够正常工作

Now it suddenly works. But the URL gets rewritten in FireFox, while in Chrome it works properly

更新 似乎与火狐的问题是由一个301重定向我之前使用造成的,缓存已经被刷新。它正常工作了。

UPDATE Seems that the problem with Firefox was caused by a 301-redirect I used earlier, the cache had to be flushed. for it to work properly again

推荐答案

从比赛中删除斜线:​​

Remove leading slash from match:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^m\.skynet\.com$
RewriteCond %{REQUEST_URI} !^/mobile/final/
RewriteRule ^(.*)$ /mobile/final/$1 [L,NC]

  • 的.htaccess 是每个目录指令和Apache条从重写规则 URI的当前目录路径(从而导致斜线)格局。
  • 您需要的RewriteCond%{REQUEST_URI}!^ /移动/最后/ 来prevent循环。
    • .htaccess is per directory directive and Apache strips the current directory path (thus leading slash) from RewriteRule URI pattern.
    • You need RewriteCond %{REQUEST_URI} !^/mobile/final/ to prevent looping.
    • 这篇关于从子域子目录路径htaccess的内部重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆