2

我在其管理面板中使用 godaddy 作为主机我有 .htaccess 文件,如下所示

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /core.php [L]
</IfModule>

我进行了设置以将其强制为 https,如下所示

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%(HTTP-HOST)%{Request-URI} [L,R=301]
</IfModule>

谁能告诉我在哪里放置 core.php 规则。我的 core.php 给出如下

<?php
error_reporting( E_ALL );

require_once( "ccioo/Template/class.Page.php" );
header( "Content-Type: text/html; charset=utf-8" );
if ( function_exists( "date_default_timezone_set" ) ) {
    date_default_timezone_set( "Asia/Taipei" );
}
$myPage = new Page();
$myPage->Output();
?>

更新:

所以我想要的是要么我输入 www.myfavouriteweb.com 要么https://www.myfavouriteweb.com它应该重定向到https://www.myfavouriteweb.com

4

1 回答 1

0

您可以DirectoryIndex从 apache使用

DirectoryIndex = core.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%(HTTP-HOST)%{Request-URI} [L,R=301]
</IfModule>

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ?original_request=$1 [QSA,L]

在这种情况下,您可以$_GET["original_request"]在您的core.phpIf you need the original request

例如

https://your_site.com/something

然后在你的 core.php

<?php
    if(isset($_GET["original_request"])){
        //here your code
        echo $_GET["original_request"];
    }else{
        //if acces directly to https://your_site.com  (without 'something')
        echo "direct acces";
    }
?>

在此示例something中,您的服务器中并不真正存在......它在core.php

于 2019-03-04T15:41:40.280 回答