gpt4 book ai didi

php - CodeIgniter:使用 HTTPS 和 AWS 时如何从 url 中删除 index.php

转载 作者:可可西里 更新时间:2023-10-31 23:46:03 26 4
gpt4 key购买 nike

我使用 HTTPS 作为主要 url,并且根据 Google SEO 指南,我必须设置以下重定向

  1. http://example.com/https://example.com
  2. http://www.example.com/https://example.com
  3. https://www.example.com/https://example.com

我配置的重定向非常适用于主页。但是对于内部页面,只有第一个有效,而第二个和第三个在 url 中添加 index.php。

示例

https://www.example.com/index.php/mobiles/apple/apple-iphone-sehttps://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[点]pk

最佳答案

RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] 上方添加以下两行解决了问题

RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

关于php - CodeIgniter:使用 HTTPS 和 AWS 时如何从 url 中删除 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36444935/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com