在 .htaccess 中为文件夹创建 301 重定向到子域并将 www 重定向到非 www
我到处搜索并使用了一些示例,但它们不能满足我的特定需求,因此为什么我在这里询问是否有人可以提供帮助?我知道下面的 http:: 不正确,只是因为我无法在这里发布链接。
我想将 http:://www.mysite.co.uk/ 重定向到 http:://mysite.co.uk/ 同时也能够重定向
- http://www.mysite.co.uk/mysub/ 2. http://mysite.co.uk/mysub/ 到 3. http:://mysub.mysite.co.uk/
1. 和 2. 中的所有文件应重定向到 3. 中的等效文件。
例如:http:://www.mysite.co.uk/mysub /file.html 和 http:://mysite.co.uk/mysub/file.html 都应该转到 http:://mysub.mysite.co.uk/file.html
这仅影响子域,所以站点根目录中的其他文件夹和文件不受影响。
如果有人可以帮助我理解并在 .htaccess 文件中编写 301 重定向的代码,我将非常感激!谢谢!
I've searched everywhere and used some examples but they don't meet my specific needs, hence why I'm asking here if anyone can please help? I know the http:: below isn't correct, it's just because I can't post links here.
I'd like to redirect http:://www.mysite.co.uk/ to http:://mysite.co.uk/
whilst also being able to redirect
- http:://www.mysite.co.uk/mysub/
and 2. http:://mysite.co.uk/mysub/
to 3. http:://mysub.mysite.co.uk/
All files in 1. and 2. should be redirected to their equivelant in 3.
For example: http:://www.mysite.co.uk/mysub/file.html AND http:://mysite.co.uk/mysub/file.html should both go to http:://mysub.mysite.co.uk/file.html
This is to affect the subdomain only, so that other folders and files in the site root aren't affected.
If anyone could help me understand and write the code for the 301 redirect in a .htaccess file I'd really really appreciate it! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您在 .htaccess 文件中需要的代码:
This is the code you'll need in your .htaccess file: