htaccess的秩序规则HTTPS(使用前pression引擎) [英] https in htaccess and order of rules (using Expression Engine)

查看:113
本文介绍了htaccess的秩序规则HTTPS(使用前pression引擎)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建在离pression引擎网站的需求,一部分是HTTPS。该网站还使用新的域名(新www.example-new.com旧www.example.old.com)。

I'm building a site in expression engine that part of needs to be https. The site is also using a new domain name (new one www.example-new.com the old one www.example.old.com).

我想要做以下的事情:

  1. 删除的index.php
  2. 力WWW
  3. 力HTTPS的任何URL启动www.example.old.com/extranet
  4. 在重定向HTTPS URL中是不www.example.old.com/extranet(如www.example.old.com/news到http

我有以下的code到目前为止,工程前两个要求:

I have the following code so far that works for the first two requirements:

    <IfModule mod_rewrite.c>
RewriteEngine On
# Force www
RewriteCond %{HTTP_HOST} ^example-new.com$ [NC]
RewriteRule ^(.*)$ http://www.example-new.com/$1 [R=301,L] 

# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>
AddType x-httpd-php53 .php

我似乎在圈子里是想圆的,所以我两个问题,这将帮我写的其他重写(虽然随时分享建议...):

I seem to be going round in circles, so I've two questions that will help me write the other rewrites (although feel free to share suggestions...):

1)如果$ C $下要求3和4之前中删除的index.phpcode定位?

1) Should the code for requirements 3 and 4 be positioned before "removes index.php" code?

2)是否位置对将从旧网站,例如未来的重定向任何影响www.example-old.com/some-link-here.asp将被重定向到www.example-new.com/some-new-link-here~~V

2) Does the position have any bearing on the redirects that will be coming from the old site e.g. www.example-old.com/some-link-here.asp will be redirected to www.example-new.com/some-new-link-here

谢谢

格雷戈尔

推荐答案

1)的防爆pressionEngine网址

RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

2)添加'WWW'给所有的URI

2) Add 'www' to all URIs

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

3)强制https://开头的任何URI开始/外网

3) Force https:// for any URI starting with /extranet

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/extranet(.*)$ [NC]
RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]

4)重定向https://开头的URI不属于/外网

4) Redirect https:// URIs that are not /extranet

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/extranet(.*)$ [NC]
RewriteRule . http://%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]


全部放在一起,这里是你的一套完整的规则集的:

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine on

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

    RewriteCond %{HTTPS} off
    RewriteCond %{REQUEST_URI} ^/extranet(.*)$ [NC]
    RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]

    RewriteCond %{HTTPS} on
    RewriteCond %{REQUEST_URI} !^/extranet(.*)$ [NC]
    RewriteRule . http://%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]

    RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

这篇关于htaccess的秩序规则HTTPS(使用前pression引擎)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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