Mod 重写假子域?
我确实尝试了很多方法,但没有成功。 我想要一个 .Htaccess 代码来执行以下操作:
我想重命名它: http://www.mydomain.com /媒体 --> http://media.mydomain.com
因此,通过示例而不是调用此: http://www.mydomain.com/media/XXX/picture.jpg 我会打电话:http://media.mydomain.com/XXX/picture.jpg
谢谢
I really tried tons of methods but i'm not successful.
I want a .Htaccess code to do the following :
I want to rename this : http://www.mydomain.com/media --> http://media.mydomain.com
So, By example instead of calling this : http://www.mydomain.com/media/XXX/picture.jpg
i will call : http://media.mydomain.com/XXX/picture.jpg
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它会是这样的:
It's gonna be like this:
确保 rewrite_module 已加载,例如;
然后添加以下内容(到您的 .htaccess):
Cond 仅匹配 www.mydomain.com。然后,规则将使用第一个“/”(将包含在 $2 中)将 URL 分成 2 个,重写并重定向。
Make sure rewrite_module is loaded, something like;
Then add the following (to your .htaccess):
The Cond will only match www.mydomain.com. The Rule then will split the URL into 2 using the first '/' (which will be included in $2), rewrite and redirect.
如果您想要相反的(请参阅罗杰的评论)并且不重定向用户
另外,请参阅此处: http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
If you want the opposite (see Roger's comment) and without redirecting the user
Also, see here: http://httpd.apache.org/docs/1.3/misc/rewriteguide.html