为什么此.htaccess文件mod_rewrite无法正常工作? [英] Why is this .htaccess file mod_rewrite not working?

查看:103
本文介绍了为什么此.htaccess文件mod_rewrite无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MAMP和CodeIgniter. 我网站的根目录是:/Users/Roy/Websites/CodeIgniter-3.0.2 在网站"文件夹中,我还有其他一些项目,但我认为这并不重要.这是apache的httpd.conf文件: http://pastebin.com/Am0ew0C0

I'm using MAMP and CodeIgniter. The root of my website is: /Users/Roy/Websites/CodeIgniter-3.0.2 In the Websites folder I also have some other project but I don't think that matters. Here is the apache httpd.conf file: http://pastebin.com/Am0ew0C0

在我的.htaccess文件中,我使用的是以下内容:

In my .htaccess file I'm using the following:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

<IfModule authz_core_module>
   Require all denied
</IfModule>
<IfModule !authz_core_module>
   Deny from all
</IfModule>

.htaccess文件位于:/Users/Roy/Websites/CodeIgniter-3.0.2/.htaccess 我不知道为什么mod_rewrite无法正常工作,它应该消除在URL中使用index.php,因为我现在必须使用的URL是:

the .htaccess file is located at: /Users/Roy/Websites/CodeIgniter-3.0.2/.htaccess I have no idea why the mod_rewrite isn't working, it's supposed to eliminate the use of index.php in the url because the URL I have to use now is: http://localhost:8888/CodeIgniter-3.0.2/index.php/about

我希望成为: http://localhost:8888/CodeIgniter-3.0.使用2/about PHP版本5.6.10. .htaccess文件未被apache读取,这是这里的问题,如何解决?

And I would like that to become: http://localhost:8888/CodeIgniter-3.0.2/about PHP version 5.6.10 is used. the .htaccess file is not being read by apache, that is the problem here, how to fix it?

推荐答案

问题已解决,无需将安装了MAMP的httpd.conf弄乱.只需获取CodeIgniter并将其放置在MAMP内的htdocs文件夹中即可.之后,在CodeIgniter文件夹(而不是其中的应用程序文件夹)中创建一个.htaccess文件,并使用以下代码:

Problem solved, there is no need to mess with the httpd.conf with MAMP installed. Simply get CodeIgniter and place it in the htdocs folder inside MAMP. After that create a .htaccess file inside the CodeIgniter folder (not the application folder inside there) and use the following code:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /ci/
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

现在您有了干净的URL,不再需要使用/index.php/about,而只需执行/about.

Now you have clean URL's and no longer need to use /index.php/about but can just do /about.

这篇关于为什么此.htaccess文件mod_rewrite无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆