我要建在离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).
我想要做以下的事情:
删除的index.php 力WWW 力HTTPS的任何URL启动www.example.old.com/extranet 在重定向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>