【发布时间】:2016-07-26 11:46:16
【问题描述】:
我使用 HTTPS 作为主要网址,根据 Google SEO 指南,我必须设置以下重定向
- http://example.com/ 到 https://example.com
- http://www.example.com/ 到 https://example.com
- https://www.example.com/ 到 https://example.com
我配置的重定向非常适合主页。但是对于内部页面,只有第一个有效,而第二个和第三个在 url 中添加 index.php。
示例
https://www.example.com/index.php/mobiles/apple/apple-iphone-se 到 https://example.com/index.php/mobiles/apple/apple-iphone-se
我在 .htaccess 中使用以下代码
RewriteEngine On
#Block access for libwww-perl user-agent
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteBase /
# Removes access to the system folder by users.
# Additionally this will allow you to create a System.php controller,
# previously this would not have been possible.
# 'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^52\.34\.179\.108
RewriteRule (.*) https://priceoye.pk/$1 [R=301,L]
- 托管:AWS (httpd)
- 网址:PriceOye[dot]pk
【问题讨论】:
-
您能否澄清一下“第一”、“第二”和“第三”的含义?您指的是帖子开头列出的规则或网址吗?此外,检查 config.php 中 $config['index_page'] 的值并将其设置为 ''(空字符串)。
-
文章开头列出的网址。 $config['index_page'] 配置正确,因为问题中提到的 url 集 1 正在工作
标签: php .htaccess codeigniter amazon-web-services