.htaccess 有头痛的代码点火器模块重写~!

.htaccess 有头痛的代码点火器模块重写~!,.htaccess,codeigniter,mod-rewrite,.htaccess,Codeigniter,Mod Rewrite,我读了很多codeigniter的mod_重写,其中很多都在谈论创建一个.htaccess文件,并在文件中使用类似的内容 我是codeigniter的初学者,所以我从youtube教程中学习。 起初我只安装了Apache2.2来运行我的php,在使用带有mod_rewrite的codeigniter之后,我意识到安装wamp更容易,所以我卸载了apache,mysql,然后安装了wamp,它拥有一切 之后,我继续在youtube上学习关于mod_write的教程。我在wamp中激活了模块 在ci

我读了很多codeigniter的mod_重写,其中很多都在谈论创建一个.htaccess文件,并在文件中使用类似的内容

我是codeigniter的初学者,所以我从youtube教程中学习。 起初我只安装了Apache2.2来运行我的php,在使用带有mod_rewrite的codeigniter之后,我意识到安装wamp更容易,所以我卸载了apache,mysql,然后安装了wamp,它拥有一切

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

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

<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>
事情不顺利。我得到了404的错误,然后我尝试了一些东西

RewriteBase /ci_intro/
甚至还删除了整个项目,因为我在尝试mod_write之前备份了一些东西。甚至在我找回备份后。我仍然没有得到错误404页面

我只是一直在

因为我在使用wamp,当我转到我的本地主机时,有一个部分说我的项目是ci_简介…我点击它,上面的图片就会出来。 我把鼠标放在上面,检查当鼠标放在上面时链接显示了什么

[守则]


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

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

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

我不确定您正在使用哪个WAMP发行版(有许多“WAMP”),但您可以选择:

A) 编辑Windows主机文件(C:\Windows\system32\drivers\etc\Hosts)以在本地将“www.domain.tld”解析为本地IP地址127.0.0.1(并确保VirtualHost或服务器将该域名作为其ServerName指令的一部分)

B) 使用“localhost”代替<代码>http://localhost/

C) 使用一个WAMP自动为您设置网站虚拟主机,并像WAMP Developer Pro一样具有本地DNS功能,因此上述所有内容都无关紧要


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

当我访问C:\Windows\system32\drivers\etc\hosts时,我看到的是127.0.0.1 localhost 127.0.0.1 mpa.one.microsoft.com 127.0.0.1 localhost 127.0.0.1 localhost所有其他文件都被注释掉了though@user1850712,添加行:
127.0.0.1 www.domain.tld
,保存文件,然后关闭浏览器(所有选项卡和窗口)。这将导致您的浏览器将您的假域名解析为本地系统IP(始终为127.0.0.1)。刚刚尝试过,但它只会将我带回我的localhost页面,并在URL中显示www.domain.tld,而不是localhost。我在config/routes.php中做了一些事情,因为有一个论坛在讨论它。我的firefox仍然存在我在这里讨论的相同问题,但是当我使用chrome时,在配置routes.php之后,一切都很好。重新安装firefox会有帮助吗?哦…哼…好的,在localhost中,我单击了ci_intro,然后它返回到localhost,并将www.domain.tld作为URL…然后再次单击ci_intro…链接工作,但显示www.domain.tld/ci_intro/home…似乎工作正常…在某种程度上…至少这可以让我继续学习教程…但只是想知道…如果有没有办法让它再次显示localhost?(只是好奇而已,现在没什么问题了,因为它现在可以用了)
RewriteBase /ci_intro/