首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用mod_rewrite点火器头疼~!

用mod_rewrite点火器头疼~!
EN

Stack Overflow用户
提问于 2013-05-26 15:57:39
回答 1查看 167关注 0票数 0

我读了很多codeigniter的mod_rewrite,其中很多人都在讨论如何创建一个.htaccess文件,并在文件中包含如下内容

我是codeigniter的初学者,所以我正在学习youtube教程。起初我只安装了apache2.2来运行我的php,在使用codeigniter和mod_rewrite之后,我意识到安装wamp更容易,所以我卸载了apache,mysql,然后安装了wamp,它包含了所有的东西。

在那之后,我继续在youtube上学习关于mod_write的教程。我激活了wamp中的模块。

在根文件夹ci_intro中创建了此.htaccess文件

代码语言:javascript
复制
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/

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

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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>
    # 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>

我转到config/config.php并更改了

代码语言:javascript
复制
$config['index_page'] = '';

事情并不顺利。我得到了404错误,然后我尝试了几个

代码语言:javascript
复制
RewriteBase /ci_intro/

甚至还删除了整个项目,因为我在尝试mod_write之前备份了一些内容。即使在我取回备份之后。我仍然没有得到error404页面。

我只是不断地得到..。

由于我使用的是wamp,当我转到我的本地主机时,有一个部分说我的项目是ci_intro...I,点击上面的图片就会出现。我把鼠标放在上面查看当鼠标移到链接上时显示的链接是什么

代码http://localhost/ci_intro[CODE]](http://localhost/ci_intro[CODE])

有人知道这是怎么回事吗?

EN

回答 1

Stack Overflow用户

发布于 2013-05-26 22:01:08

你得到的浏览器页面,是使用假的或未注册的域名的结果...浏览器无法将其解析为IP地址,因此它通过将您的请求重新解释为搜索词来“帮助”您。

这是因为你使用"www.domain.tld“而不是"localhost”来访问你的网站。

我不确定您使用的是哪个WAMP发行版(有许多“WAMP”),但您的选择如下:

A)编辑Windows Hosts文件(C:\Windows\system32\drivers\etc\hosts),在本地将"www.domain.tld“解析为本地IP地址127.0.0.1 (并确保您的VirtualHost或服务器在其ServerName指令中包含该域名)。

B)使用"localhost“代替...http://localhost/

C)使用WAMP,它可以自动为你设置网站VirtualHosts,并且像Wamp-Developer Pro那样具有LocalDNS功能--所以以上这些都无关紧要。

一旦你通过了,可能会有其他的问题...我猜.htaccess文件应该在DocumentRoot文件夹中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16757270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档