微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Codeigniter URL重写删除index.php

首先,我已经尝试了在这里指定的build议:

CodeIgniter删除index.PHP不工作

codeignitor:删除index.PHP不工作

CodeIgniter .htaccess index.PHP重写不在用户目录上工作

如何去除codeigniterpath中的“index.PHP

https://ellislab.com/expressionengine/user-guide/urls/remove_index.PHP.html

CodeIgniter的重写不起作用

我正试图删除地址栏上的臭名昭着的index.PHP

这是我目前的configuration:

在我的/etc/apache2/sites-available/my.website.com.conf文件中,我把这个:

有没有可能在.htaccess文件输出任何或所有可用的variables?

是否可以阻止使用.htaccess文件的传出连接?

将所有非wwwredirect到www。 为CakePHP网站

htaccess:在RewriteCond中出现一些域

摆脱CodeIgniterurl中的Index.PHP

<Directory /path/to/root/directory/> AllowOverride All Order allow,deny Allow from all </Directory>

在我的/etc/apache2/apache2.conf文件中,我把这个:

<Directory /path/to/root> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>

在我codeigniter根目录(与index.PHP相同的目录),我有一个.htaccess像这样:

<IfModule mod_rewrite> RewriteEngine On RewriteBase / #Removes access to the system folder by users. #Additionally this will allow you to create a System.PHP controller,#prevIoUsly this would not have been possible. #'system' can be replaced if you have renamed your system folder. RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.PHP?/$1 [L] #When your application folder isn't in the system folder #This snippet prevents user access to the application folder #Submitted by: Fabdrol #Rename 'application' to your applications folder name. RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /index.PHP?/$1 [L] #Checks to see if the user is attempting to access a valid file,#such as an image or css document,if this isn't true it sends the #request to index.PHP RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.PHP?/$1 [L] </ifmodule> <IfModule !mod_rewrite.c> # If we don't have mod_rewrite installed,all 404's # can be sent to index.PHP,and everything works as normal. # Submitted by: ElliotHaughin ErrorDocument 404 /index.PHP </ifmodule>

最后,我的应用程序/ config / config.PHP

$config['base_url'] = 'http://my.website.com'; $config['index_page'] = ''; $config['uri_protocol'] = 'REQUEST_URI';

当我在本地PC(运行Ubuntu 14.04)testing上述configuration时,它工作得很好。 但是,当我尝试复制我的服务器上的configuration(运行Ubuntu 14.04),不知何故,它不工作。

这样做:

http://my.website.com/ <<显示认的Codeigniter欢迎页面

http://my.website.com/controller_name/ <<显示

未find在此服务器上未find请求的URL /login。 Apache / 2.4.7(Ubuntu)服务器在my.website.com端口80

http://my.website.com/index.PHP/controller_name <<显示页面,但是静态文件(即JS / CSS /图像)的URL没有正确提取,因为打印这个:

<link rel="stylesheet" href="assets/styles/material-design-icons.css" type="text/css" /> <link rel="stylesheet" href="assets/styles/font.css" type="text/css" /> <link rel="stylesheet" href="assets/styles/app.css" type="text/css" />

会从源代码检查器中看到附加index.PHP

在这里错过了什么? 有人能指点我正确的方向吗?

谢谢。

编辑#1下面是我的文件夹结构

编辑#2我可以确认mod_rewrite已启用

503 htaccess文件只能部分工作

如何使用htaccess从url中删除文件名称

如何在.htaccess中写入“if … else”mod_rewrite语句

在htaccess中添加GET参数

.htaccess重写友好的URL

好的,你提到了很多关于你的问题的Stack链接

更改此设置

$config['base_url'] = ''; $config['index_page'] = ''; $config['uri_protocol'] = 'AUTO';

添加到.htaccess

<Ifmodulee mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.PHP/$1 [L] </Ifmodulee>

注意:在localhost index.PHP某些时间不会被删除

包括你的CSS / JS /图像

CSS: <link rel="stylesheet" href="<?PHP echo base_url()?>assets/styles/material-design-icons.css" type="text/css" />

JS: <script type="text/javascript" src="<?PHP echo base_url(); ?>assets/js/in/easing.js"></script>

图: <img src="<?PHP echo base_url()?>assets/image/logo.jpg" alt=""/>

所以文件结构会

- application - assets - style - material-design-icons.css - font.css - app.css - js - easing.js - image - logo.jpg - index.PHP - .htaccess(Post in my code)

编辑01

在config/routes.PHP

$route['default_controller'] = "";//give default controller name $route['404_override'] = '';

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐