Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.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 用.htaccess破坏了我的网站!如何重置?_Php_.htaccess - Fatal编程技术网

Php 用.htaccess破坏了我的网站!如何重置?

Php 用.htaccess破坏了我的网站!如何重置?,php,.htaccess,Php,.htaccess,我试图用删除URL中的“.php”,但现在我的网站完全崩溃了。索引页可以工作,但其他所有内容都会打印出来 mysite.com/subfolder/subfolder?about.php 应该是什么时候 mysite.com/about.php 我尝试过修改文件,但无法恢复原样 有什么方法可以让我重置一切吗?我尝试过寻找解决方案并关闭/打开重写引擎,但没有成功 如果这很重要的话,我会用它来主持 # @author: Chris Hjorth, www.chrishjorth.com # Make

我试图用删除URL中的“.php”,但现在我的网站完全崩溃了。索引页可以工作,但其他所有内容都会打印出来

mysite.com/subfolder/subfolder?about.php

应该是什么时候

mysite.com/about.php

我尝试过修改文件,但无法恢复原样

有什么方法可以让我重置一切吗?我尝试过寻找解决方案并关闭/打开重写引擎,但没有成功

如果这很重要的话,我会用它来主持

# @author: Chris Hjorth, www.chrishjorth.com
# Make index.php the directory index page
DirectoryIndex index.php
#Protect the .htaccess files
<Files .htaccess>
order allow,deny
deny from all
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder/
# START CodeIgniter ------------------------------------------------------------------------------------------------------------
# based on http://www.danielwmoore.com/extras/index.php?topic=7691.0 and http://ellislab.com/forums/viewthread/132758/
# Redirect default controller to "/".
# This is to prevent duplicated content. (/welcome/index =&gt; /)
RewriteRule ^(welcome(/index)?)/?$ /subfolder/ [L,R=301]
# Remove /index/ segment on the URL, again to prevent duplicate content.
RewriteRule ^(.*)/index/? $1 [L,R=301]
# Remove trailing slashes, also to remove duplicate content
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Remove multiple slashes in between, just to remove the possibility of fabricating crazy links.
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
# Ignore certain files and folders in this rewrite
RewriteCond $1 !^(index\.php|assets|frameworks|uploads|robots\.txt|favicon\.ico)
# [NC] = no case - case insensitive
# [L] = Last rule, last rewrite for this set of conditions
# [QSA] = Query String Append, should be used to prevent all redirects from going to your default controller, which happens on
# some server configurations.
RewriteRule ^(.*)$ /subfolder/index.php?$1 [NC,L,QSA]
# END CodeIgniter --------------------------------------------------------------------------------------------------------------
</IfModule>
# If Mod_ewrite is NOT installed go to index.php
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
#@作者:克里斯·霍思,www.chrishjorth.com
#使index.php成为目录索引页
DirectoryIndex.php
#保护.htaccess文件
命令允许,拒绝
全盘否定
重新启动发动机
重写基本/子文件夹/
#启动点火器------------------------------------------------------------------------------------------------------------
#基于http://www.danielwmoore.com/extras/index.php?topic=7691.0 和http://ellislab.com/forums/viewthread/132758/
#将默认控制器重定向到“/”。
#这是为了防止重复内容。(/welcome/index=/)
重写规则^(欢迎(/index)?)/?$/子文件夹/[L,R=301]
#删除URL上的/索引/段,以防止重复内容。
重写规则^(.*)/索引/$1[L,R=301]
#删除尾部斜杠,也可以删除重复内容
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#删除多个斜杠之间,只是为了消除制造疯狂链接的可能性。
RewriteCond%{REQUEST_URI}^(.*)/(.*)$
重写规则%1/%2[R=301,L]
#忽略此重写中的某些文件和文件夹
1美元^(索引\.php |资产|框架|上传| robots\.txt | favicon\.ico)
#[NC]=无大小写-不区分大小写
#[L]=最后一条规则,这组条件的最后一次重写
#[QSA]=查询字符串追加,应用于防止所有重定向转到默认控制器,这发生在
#一些服务器配置。
重写规则^(.*)$/subfolder/index.php?$1[NC,L,QSA]
#端部点火器--------------------------------------------------------------------------------------------------------------
#如果未安装Mod_ewrite,请转到index.php
ErrorDocument 404/index.php
[已解决]:


问题是缓存。Firefox已经保存了htaccess配置,所以无论我做了什么更改,它都不会删除中断的重写。谢谢大家的支持

对CodeIgniter+htaccess的搜索给出了以下htaccess


重新启动发动机
# !重要的在这里设置您的基础,不要忘记尾随和前导
#砍。
#如果您的页面位于
#  http://www.example.com/mypage/test1
#然后使用
#重写base/mypage/test1/
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php,一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php
虽然这不是真正的CodeIgniter特殊,但它应该会让您重新回到正轨。从那时起,请仔细阅读文档,了解您正在更改的内容


打开config.php并执行以下操作

$config['index_page'] = "index.php"

替换

$config['uri_protocol'] ="AUTO" 

并在HTACCESS文件中放入以下代码

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

在这里发布你的.htaccess。所以只有我们知道是什么错误。我在文本中链接了它,但是如果你愿意,我也可以在这里发布。你为什么不删除所有内容,保存文件,重新加载网站,然后再次编辑它?每次都为我工作。不要忘记使用F5或浏览器按钮刷新网站。有些浏览器倾向于缓存.htaccess,这会阻止他们使用缓存的版本。如果您对
.htaccess
文件所做的更改破坏了您的站点,那么只需删除最后一次更改,它就会恢复到以前的状态。Apache读取每个页面/资源访问的
.htaccess
文件,因此仅影响Apache的活动(如果存在)。撤消上一次更改,您就回到了原来的状态。要补充@Riggs所说的内容,请务必在修补htaccess文件之前进行备份,这样,如果您破坏了它,您就可以重置为工作状态。
$config['uri_protocol'] ="AUTO" 
$config['uri_protocol'] = "REQUEST_URI"
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]