我在管理面板中使用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
发布于 2019-03-04 15:41:40
您可以使用apache的DirectoryIndex。
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.php。
例如。
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处理的
https://stackoverflow.com/questions/54985322
复制相似问题