我试图用this从网址中删除“.php”,但现在我的网站完全被破坏了。索引页面有效,但其他所有内容都打印出来
mysite.com/subfolder/subfolder?about.php
什么时候应该
mysite.com/about.php
我已经尝试过修改文件,但无法恢复原来的状态......
有什么方法可以重置一切吗?我已经尝试过寻找解决方案并将RewriteEngine关闭/打开,但那里没有运气......
如果重要,我正在使用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 => /)
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配置,因此无论我改变什么,它都不会删除破坏的重写。所以感谢人们的投入!
答案 0 :(得分:0)
对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,它应该让你再次回到正轨。从那里开始,请仔细查看文档以了解您要更改的内容
答案 1 :(得分:0)
打开config.php并执行以下替换
$config['index_page'] = "index.php"
到
$config['index_page'] = ""
只需替换
$config['uri_protocol'] ="AUTO"
到
$config['uri_protocol'] = "REQUEST_URI"
AND IN HTACCESS FILE下面的代码
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]