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


Broke my website with .htaccess! How to reset?

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

mysite.com/subfolder/subfolder?关于.php

什么时候应该是

mysite.com/about.php

我试过修改文件,但无法恢复到原来的状态。。。

有什么办法可以重置所有内容吗?我尝试过搜索解决方案并关闭/打开"重写引擎",但没有成功。。。

如果这很重要的话,我正在使用One.com进行托管。

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

[已解决]:

问题出在缓存上。Firefox保存了htaccess配置,所以无论我做了什么更改,它都不会删除损坏的重写。感谢大家的投入!

在CodeIgniter+htaccess上的搜索得到了以下htaccess。

https://gist.github.com/philipptempel/4226750

<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  #  http://www.example.com/mypage/test1
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /
  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>

虽然这并不是真正的CodeIgniter特别之处,但它应该会让你再次回到正轨。从那时起,请仔细查看文档,以了解您正在更改的

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

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

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

$config['index_page'] = ""

只需更换

$config['uri_protocol'] ="AUTO" 

$config['uri_protocol'] = "REQUEST_URI"

在HTACCESS文件中放入以下代码

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