Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
从CodeIgniter中的URL中删除index.php_Php_.htaccess_Codeigniter - Fatal编程技术网

从CodeIgniter中的URL中删除index.php

从CodeIgniter中的URL中删除index.php,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我读过关于这方面的帖子,但没有回答我的问题 我已经设置了我在CodeIgniter论坛上找到的所有内容,以及SO的问题 目前我有以下设置: .htaccess文件 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / #'system' can be replaced if you have renamed your system folder. RewriteCond %{REQUEST_U

我读过关于这方面的帖子,但没有回答我的问题 我已经设置了我在CodeIgniter论坛上找到的所有内容,以及SO的问题

目前我有以下设置: .htaccess文件

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    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

    #This last condition enables access to the images and css folders, and the robots.txt file
    RewriteCond $1 !^(index\.php|(.*)\.swf|images|robots\.txt|css|docs|cache)
    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.
    ErrorDocument 404 /application/errors/404.php
</IfModule>

RewriteRule^crud\u demo/(.*)$crud\u demo/index.php/$1

测试URL重写


我认为CodeIgniter有自己的方式来路由URL,就像其他PHP框架一样。看看这里:

重写规则^crud\u demo/(.*)$crud\u demo/index.php/$1

测试URL重写


我认为CodeIgniter有自己的方式来路由URL,就像其他PHP框架一样。看看这里:

如果crud\u demo是根目录的子文件夹,那么您应该更改

RewriteBase/


RewriteBase/crud\u demo

如果crud\u demo是根目录的子文件夹,则应更改

RewriteBase/


RewriteBase/crud\u demo

在ubuntu的
/etc/apache2/sites available/000 default.conf
虚拟主机文件中将AllowOverride None更改为AllowOverride All


在windows中的虚拟主机文件
/etc/apache2/sites available/default.conf
中将AllowOverride None更改为AllowOverride All

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All    <---- replace None with All
    </Directory>
    <Directory /var/www >
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All   <---  replace None with All
            Order allow,deny
            allow from all
    </Directory>
....

它肯定会起作用。

在ubuntu的
/etc/apache2/sites available/000 default.conf
中,将我的虚拟主机文件中的AllowOverride None更改为AllowOverride All


在windows中的虚拟主机文件
/etc/apache2/sites available/default.conf
中将AllowOverride None更改为AllowOverride All

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride All    <---- replace None with All
    </Directory>
    <Directory /var/www >
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All   <---  replace None with All
            Order allow,deny
            allow from all
    </Directory>
....

它肯定会工作。

我认为我的.htaccess不适用。我认为config文件夹中应该有一个
route.php
文件。你试过了吗?我想我的.htaccess不适用。我想在config文件夹中应该有一个
route.php
文件。你试过了吗?目录是C:/wamp/www/crud\u demoYeah基地需要更改,尝试目录是C:/wamp/www/crud\u demoYeah基地需要更改,试试看在做了htaccess更改之后是否重新启动了apache实例?在做了htaccess更改之后是否重新启动了apache实例?谢谢我会一直在那里提供帮助谢谢我会一直在那里提供帮助
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]