如何将请求重定向到example.com到www.example.com与mod

编程入门 行业动态 更新时间:2024-10-23 14:20:15
本文介绍了如何将请求重定向到example到www.example与mod_rewrite的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的.htaccess通过文字preSS的坐在我的根目录下生成。

This is my .htaccess generated by wordpress that sits in my root directory.

我需要修改/添加到它,所有的传入流量定向到的 www.example 的,而不是 example 的。

I need to modify/add to it, to direct all incoming traffic to www.example, instead of example.

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress

如果有人想解释什么上述所有不还,这将是AP preciated为好。

If someone wants to explain what all the above does also, that would be appreciated as well.

推荐答案

做你的要求,你要添加:

To do what you requested, you want to add:

RewriteCond %{HTTP_HOST} ^www.mysite$ [NC] RewriteRule ^(.*)$ mysite/$1 [R=301,L]

您可以放置​​其间的&LT; IfModule mod_rewrite.c&GT; 括号后的的RewriteBase

You can place that inbetween the <IfModule mod_rewrite.c> brackets after RewriteBase

至于什么字preSS'htaccess的code做(没有测试):看来,以测试对任何直接链接到的文件和目录,而不是通过它通常会采取重写规则通过他们你链接并将其发送到index.php

As for what Wordpress' htaccess code does (didn't test it): It seems to test for any direct links to files and directories and not pass them through the RewriteRule which will normally take your link and send it to index.php

所以,如果你的链接是www.mysite/some/page,它确保/一些/页不是直接的文件链接或实际的Web目录,如果没有,那么它传递请求到的index.php它解析它,以显示正确的单词preSS页。

So if your link is for www.mysite/some/page, it makes sure /some/page isn't a direct file link or an actual web directory and if it isn't, then it passes the request to index.php which parses it to display the correct Wordpress page.

更多推荐

如何将请求重定向到example.com到www.example.com与mod

本文发布于:2023-11-01 11:40:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549246.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   重定向   mod   www

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!