code点火器 - URL重写 [英] Code Igniter - URL Rewrite
问题描述
嘿,我试图让一个项目的工作,但我有重写模块的麻烦。
我正在WAMP通过Windows XP。我改变httpd.conf来改变本地主机的根:
Hey, i'm trying to get a project to work, but i am having trouble with the rewrite module.
I'm running Wamp over Windows XP. I changed httpd.conf to change the root of localhost to:
DocumentRoot "C:/wamp/www/project/docroot/"
我的htaccess
I have htaccess
RewriteEngine On
RewriteBase /
我的Apache有重写模块激活。
我BASE_URL()在config.php是'HTTP://本地主机/'
在routes.php文件我有:
my Apache has the rewrite module Activated.
my base_url() in config.php is 'http://localhost/'
in routes.php i have:
$route['default_controller'] = "home";
$route['our-recipes'] = "recipes";
and more pairs
当我将浏览器指向的http://本地主机/ 我让我的网站的网页,但是当我点击喜欢我们的菜谱它加载任何内在联系,但我得到了相同的网页,在地址栏上的新网址。如果我尝试访问的http://本地主机/菜谱我得到了相同的结果。
when i point the browser to http://localhost/ i get the homepage of my site, but when i click on any internal link like to 'our-recipes' it loads but i get the same homepage, with the new url on the location bar. if i try to access 'http://localhost/recipes' i get the same result.
这是我的文件夹结构:
this is my folder structure:
任何人都可以请解决这个问题对我来说??
Can anyone please solve this for me??
推荐答案
给这个一杆(从的维基)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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>
这篇关于code点火器 - URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!