Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 代码点火器中的缩短URL_Php_.htaccess_Codeigniter - Fatal编程技术网

Php 代码点火器中的缩短URL

Php 代码点火器中的缩短URL,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我正在为一个网站开发一个CodeIgniter框架。我上传了我的网站,它工作了。现在我想做的是做一些只有几个人知道但仍然容易记住的秘密URL快捷方式。我想让www.mywebsite.com/secretpage加载我的秘密页面。然而,codeigniter似乎不允许直接访问文件。我听说我可以使用.htaccess使用url路由,但它似乎不起作用 使用codeigniter路由可以缩短URL。将url帮助程序添加到自动加载 您无法直接访问php,因为控制器顶部的代码会阻止它 无法直接访问的示例

我正在为一个网站开发一个CodeIgniter框架。我上传了我的网站,它工作了。现在我想做的是做一些只有几个人知道但仍然容易记住的秘密URL快捷方式。我想让www.mywebsite.com/secretpage加载我的秘密页面。然而,codeigniter似乎不允许直接访问文件。我听说我可以使用.htaccess使用url路由,但它似乎不起作用

使用codeigniter路由可以缩短URL。将url帮助程序添加到自动加载

您无法直接访问php,因为控制器顶部的代码会阻止它

无法直接访问的示例

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
也可以使用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。

什么似乎不起作用?你试过用什么粘贴代码
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]