Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 代码点火器未工作_Php_.htaccess_Codeigniter - Fatal编程技术网

Php 代码点火器未工作

Php 代码点火器未工作,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我在我的站点上使用这个htaccess文件来删除index.php RewriteEngine on RewriteCond $1 !^(index\.php) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L,QSA] 但此文件不起作用。Apache模块中已启用重写。使用的codeigniter版本为2.0.1。read 我已经

我在我的站点上使用这个htaccess文件来删除index.php

RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
但此文件不起作用。Apache模块中已启用重写。使用的codeigniter版本为2.0.1。

read


我已经在没有codeigniter的情况下测试过了,它是有效的

我在htdocs下创建了一个名为“demo”的文件夹。我将“.htaccess”与您的内容+附加行(RewriteBase)放在一起:

然后是下面的“index.php”:


将此复制到.htaccess中

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CI_FOLDER/
#CI_FOLDER is the Location of your CI files.

#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>  

重新启动发动机
重写基本/CI_文件夹/
#CI_文件夹是CI文件的位置。
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^(.*)$/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#提交人:Fabdrol
#将“应用程序”重命名为应用程序文件夹名称。
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$/index.php?/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php

将此代码放入CI\u文件夹的.htaccess文件中

 <IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteBase /foldername/ 
    RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /foldername/index.php?/$1 [QSA,L] 
    </IfModule>
    # BEGIN Expire headers <ifModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault "access plus 5 seconds"
        ExpiresByType image/x-icon "access plus 2592000 seconds"
        ExpiresByType image/jpeg "access plus 2592000 seconds"
        ExpiresByType image/png "access plus 2592000 seconds"
        ExpiresByType image/gif "access plus 2592000 seconds"
        ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
        ExpiresByType text/css "access plus 604800 seconds"
        ExpiresByType text/javascript "access plus 216000 seconds"
        ExpiresByType application/javascript "access plus 216000 seconds"
        ExpiresByType application/x-javascript "access plus 216000 seconds"
        ExpiresByType text/html "access plus 600 seconds"
        ExpiresByType application/xhtml+xml "access plus 600 seconds" </ifModule>
    # END Expire headers

    # BEGIN Cache-Control Headers <ifModule mod_headers.c>
        <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
            Header set Cache-Control "public"
        </filesMatch>
        <filesMatch "\.(css)$">
            Header set Cache-Control "public"
        </filesMatch>
        <filesMatch "\.(js)$">
            Header set Cache-Control "private"
        </filesMatch>
        <filesMatch "\.(x?html?|php)$">
            Header set Cache-Control "private, must-revalidate"
        </filesMatch> </ifModule>
    # END Cache-Control Headers
    # BEGIN GZIP COMPRESSION <IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule>
    # END GZIP COMPRESSION

选项+FollowSymLinks
重新启动发动机
重写基本/文件夹名称/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$/foldername/index.php?/$1[QSA,L]
#开始过期标题
过期于
ExpiresDefault“访问加5秒”
ExpiresByType图像/x图标“访问加2592000秒”
ExpiresByType图像/jpeg“访问时间加2592000秒”
ExpiresByType图像/png“访问加2592000秒”
ExpiresByType image/gif“访问时间加2592000秒”
过期按类型应用程序/x-shockwave-flash“访问加2592000秒”
ExpiresByType文本/css“访问时间加604800秒”
ExpiresByType文本/javascript“访问时间加216000秒”
ExpiresByType应用程序/javascript“访问时间加216000秒”
ExpiresByType应用程序/x-javascript“访问时间加216000秒”
ExpiresByType text/html“访问加600秒”
ExpiresByType应用程序/xhtml+xml“访问加600秒”
#结束过期标头
#开始缓存控制头
标头集缓存控制“公共”
标头集缓存控制“公共”
标头集缓存控制“专用”
标题集缓存控制“专用,必须重新验证”
#结束缓存控制头
#开始GZIP压缩mod|GZIP|u在Yes mod|GZIP|u item|u include file\.(html?;txt | css | js | php | pl)$mod|GZIP|u包含处理程序^cgi脚本$mod u GZIP|u包含mime^text/*mod GZIP|u项包含mime^application/x-javascript.*mod u GZIP|项排除mime图像/*mod GZIP|项排除内容:*
#结束GZIP压缩

检查Apache站点配置文件。在Ubuntu 14.04上,文件将是/etc/apache2/sites available/site.conf

sudo service apache2 restart
像这样换行

AllowOverride None
对此

AllowOverride All
重新启动Apache以加载更新的site.conf

sudo service apache2 restart

这为我解决了问题。

这可能是Codeigniter 3的最新解决方案

把这个放在你的根文件夹上

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

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
转到apache/apache_version/conf/httpd.conf(Im使用Laragon)

放在httpd.conf的末尾

Listen 9595
<VirtualHost *:9595>
DocumentRoot "C:\laragon\www\capstone_project"
<Directory "C:\laragon\www\capstone_project">
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>
听9595
DocumentRoot“C:\laragon\www\capstone\u项目”
命令允许,拒绝
通融
允许超越所有

重新启动apache并查看它是否工作。

尝试删除第一个
RewriteCond
,并将
RewriteRule
模式更改为
^(?!index\.php.*)$
是否要我执行此操作?RewriteRule^(.*)^(?index\.php.*)否,
RewriteRule^(?index\.php.*)$index.php/$1[L,QSA]
。并删除
RewriteCond$1^(index\.php)
。可能重复尝试这个{RewriteRule上的RewriteEngine^(.*)$index.php/$1[L]}是的,我面临的问题是RewriteBase。非常感谢您的解决方案。嗨,穆罕默德,我已经尝试过了,但在我的域中,这也不起作用,我在hostgator共享主机上,如果我使用此代码,然后得到500个错误,我的其他域没有给出任何错误,你能建议原因是什么吗?虽然此代码可以回答这个问题,但最好在不介绍其他域的情况下解释它如何解决问题,以及为什么要使用它。从长远来看,只使用代码的答案是没有用的。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Listen 9595
<VirtualHost *:9595>
DocumentRoot "C:\laragon\www\capstone_project"
<Directory "C:\laragon\www\capstone_project">
Order allow,deny
Allow from all
AllowOverride All
</Directory>
</VirtualHost>