简体   繁体   English

代码点火器-URL重写

[英]Code Igniter - URL Rewrite

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. 我正在Windows XP上运行Wamp。 I changed httpd.conf to change the root of localhost to: 我将httpd.conf更改为localhost的根目录:

DocumentRoot "C:/wamp/www/project/docroot/"

I have htaccess 我有htaccess

RewriteEngine On
RewriteBase /

my Apache has the rewrite module Activated. 我的Apache的重写模块已激活。
my base_url() in config.php is ' http://localhost/ ' 我在config.php中的base_url()是' http:// localhost / '
in routes.php i have: 在routes.php中,我有:

$route['default_controller'] = "home";  
$route['our-recipes'] = "recipes";  
and more pairs

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. 当我将浏览器指向http:// localhost /时,我获得了我网站的主页,但是当我单击任何类似于“我们的食谱”的内部链接时,它将加载,但是我得到了相同的主页,并且新网址位置栏。 if i try to access ' http://localhost/recipes ' i get the same result. 如果我尝试访问“ http:// localhost / recipes ”,我将得到相同的结果。

this is my folder structure: 这是我的文件夹结构:
folder_structure

Can anyone please solve this for me?? 谁能为我解决这个问题?

Give this a shot (taken from the wiki ) 试一试(摘自Wiki

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM