的RewriteCond和重写规则在

的RewriteCond和重写规则在

本文介绍了的RewriteCond和重写规则在.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有位于 http://www.example.com/client 一个客户端文件夹不过,我现在已经安装了SSL的服务器上,并要添加使用.htaccess的永久重定向以便每当/客户端访问,它重定向到:的

I have a client folder located at http://www.example.com/clientHowever, I've now installed SSL on the server, and want to add a permanent redirect using HTACCESS so that whenever /client is accessed, that it redirects to: https://www.example.com/client

任何人都知道该怎么做?

Anybody know how to do that?

我重定向我的域名,在过去是这样的:

I've redirected my domains in the past like this:

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

这应该不会影响解决方案,但该网站仍必须重定向到www.example.com,然后再以 https://www.example.com/client 的如果例如的http:// WWW。 example.co.za/client 输入。

This should not affect the solution, but the site must still redirect to www.example.com FIRST, and then to https://www.example.com/client if for example, http://www.example.co.za/client is entered.

推荐答案

RewriteEngine叙述上重写规则^ /?$ https://www.example.com/client [301,NC,L]

RewriteEngine OnRewriteRule ^/?$ https://www.example.com/client [301,NC,L]

它告诉了Apache,每当网址是 https://www.example.com 或无论是与斜杠在年底,将重定向到UR /客户端

It tells the apache, whenever the url is https://www.example.com or either with slash at the end, will redirect to ur /client

这篇关于的RewriteCond和重写规则在.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 08:06