我正在为网站开发CodeIgniter框架。我上传了我的网站,它的确有效。现在我想做的是制作某种秘密的URL快捷方式,只有几个人知道但仍然容易记住。我想让www.mywebsite.com/secretpage加载我的秘密页面。但是,codeigniter似乎不允许直接访问文件。我听说我可以使用.htaccess使用url路由,但它似乎不起作用。
答案 0 :(得分:0)
使用codeigniter路由http://ellislab.com/codeigniter/user-guide/general/routing.html可以缩短URL。将url helper添加到autoload。
你无法直接访问php,因为控制器顶部的代码会阻止它。
为什么你无法直接访问。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
如何缩短路线示例。
www.yourdomain.com/secretpage /
$route['secretpage'] = "folder/controller/index";
$route['secretpage'] = "folder/controller/index";
也可以使用htaccess
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
从配置文件中删除index.php。