我通过以下方式收到404错误:
http://www1.example.me/z/account/login
虽然这些工作正常:
http://www1.example.me/z/index.php/account/login
http://www1.example.me/z/
.htaccess - 从this website得到它:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|www1) [NC]
RewriteRule ^(.*)$ http://www1.sherzod.me/z/$1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://www1.sherzod.me/z/$1 [L,R=301]
###
# 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]
# 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>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
CONFIGS:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$route['default_controller'] = "home";
更新:
在error_log中获取此信息:
[Wed Dec 28 17:54:30 2011] [notice]不能在401 ErrorDocument指令中使用完整的URL ---忽略!
没关系,修理它。
应该是:
RewriteRule ^(。*)$ z / index.php / $ 1 [L]
而不是
RewriteRule ^(。*)$ index.php / $ 1 [L]
因为代码在z文件夹中。感谢造访。 :)
答案 0 :(得分:1)
首先你去配置文件.... 然后设置$ config ['index_page'] =''; 然后创建一个扩展名为.htacess的文件,并在其中写下代码并保存在根目录
中RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
答案 1 :(得分:1)
虽然您在问题中“解决了”您的问题,但您的实施实际上是错误的。
要正确实现此功能,您应该更改RewriteBase指令,而不是将规则专门指向文件夹。
在你的情况下
RewriteBase /z/
在旁注中,您应该发布相同效果的答案,而不是修改您的问题以表明您已修复它。这可以防止问题出现在未应答的供稿等中。
答案 2 :(得分:0)
是的,您可以从.htaccess轻松删除url中的index.php,请查看url以获取更多详细信息。