我正在尝试执行这样的重定向:
header("Location: application/controllers/backend");
但当然不起作用'导致页面上出现循环警告。相反,如果我执行:
header("Location: application/controllers/backend.php");
这有效,但我不想要.php
扩展名。为什么?因为我在Route上工作,允许我在服务器的当前uri的基础上加载正确的控制器。我怎么能做到这一点?
这实际上是我的.htaccess:
RewriteEngine On
RewriteBase /AppFolderName/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]
答案 0 :(得分:1)
如果您有一个有效的网址重写htaccess,您可以通过以下方式执行此操作:
header("Location: http://www.yourwebsite.com/application/controllers/backend");
此函数可以获取项目的完整URL:
function url(){
if(isset($_SERVER['HTTPS'])){
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
}
else{
$protocol = 'http';
}
return $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}
所以,重定向代码应为:
$base_url = url();
header("Location: ".$base_url."/application/controllers/backend");
答案 1 :(得分:0)
试试这个
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
或者这个)
name = "Name: Veronica Ljunglöf"
=> "Name: Veronica Ljunglöf"
name.split[1]
=> "Veronica"