Codeigniter.htaccess
抱歉我的英语不好...
我有最基本的 CodeIgniter 设置,但无法使其工作...如果我访问该网址 http://domain.com/index.php?controllerX/method 它工作正常。
现在我希望能够访问 http://domain.com/method
我在routes.php“controllerX”上配置为默认控制器并尝试使用以下 .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
我尝试了多个 .htaccess,每次服务器都返回 403 错误。即使我的 .htaccess 仅包含第一行“RewriteEngine on”,它也会显示 403 错误。我尝试将每个文件夹设置为 chmod 777 或 755 进行测试,但这没有任何改变。
有没有办法查看哪些资源给出了 403 错误?或者我在其他地方犯了错误?
好吧,我在某处读到我需要在 htaccess 上使用“Options +FollowSymLink”...服务器向我显示 500 个错误:(
编辑 好的,现在可以使用以下 htaccess:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
Sorry for my bad english...
I have the most basic possible CodeIgniter setup and can't make it work... if i access the url
http://domain.com/index.php?controllerX/method it works fine.
Now I want to be able to access
http://domain.com/method
I configured on routes.php "controllerX" to be the default controller and try to use the follow .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
I have tried multiple .htaccess and everytime the server just returns 403 errors. Even if my .htaccess contains only the first line "RewriteEngine on", it shows 403 errors. I have tried to set every folder to chmod 777 or 755 to test and this change nothing.
Is there a way to see what resource are giving the 403 error? Or am I comiting a mistake elsewhere?
Ok, i readed somewhere that I need "Options +FollowSymLink" on my htaccess ... with that the server show me 500 errors :(
EDIT
Ok, now its working, with the follow htaccess:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将您的 .htaccess 文件更改为:
除了我们在 .htaccess 文件中所做的更改之外,我们还必须验证/更改以下设置:
Apache 读取位于 /var/www/html 目录下的 .htaccess 文件。
您可以通过编辑httpd.conf文件来做到这一点:
sudo nano /etc/httpd/conf/httpd.conf
找到该部分并将AllowOverride None更改为
现在重新启动Apache以使更改生效:
sudo systemctl restart httpd
rest 这对我有用
change your .htaccess file as:
apart from the changes we did in .htaccess file we also have to verify/changed the following setting :
Apache to read .htaccess files located under the /var/www/html directory.
You can do this by editing httpd.conf file:
sudo nano /etc/httpd/conf/httpd.conf
Find the section and change AllowOverride None to
Now restart Apache to put the change into effect:
sudo systemctl restart httpd
rest this worked for me
我认为您的问题也已在此处得到解答
I think your question is also answered here