代码点击器 - URL重写 [英] Code Igniter - URL Rewrite

查看:308
本文介绍了代码点击器 - URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我想让一个项目工作,但我有重写模块的问题。

我在Windows XP上运行Wamp。我改变httpd.conf将localhost的根目录改为:

  DocumentRootC:/ wamp / www / project / docroot / 

我有htaccess

  RewriteEngine On 
RewriteBase /

我的Apache有重写模块已启用。

config.php中的base_url()为「)

 < IfModule mod_rewrite.c> 
RewriteEngine On
RewriteBase /

#Removes用户访问系统文件夹。
#另外,这将允许您创建一个System.php控制器,
#previously这是不可能的。
#'system'可以替换,如果你已经重命名您的系统文件夹。
RewriteCond%{REQUEST_URI} ^ system。*
RewriteRule ^(。*)$ /index.php?/$1 [L]

#当应用程序文件夹不是在系统文件夹
#此代码段阻止用户访问应用程序文件夹
#提交者:Fabdrol
#Rename'application'到您的应用程序文件夹名称。
RewriteCond%{REQUEST_URI} ^ application。*
RewriteRule ^(。*)$ /index.php?/$1 [L]

#检查用户是否尝试访问一个有效的文件
#s如一个图像或CSS文档,如果这不是真的,它发送
#request到index.php
RewriteCond%{REQUEST_FILENAME}! - f
RewriteCond%{REQUEST_FILENAME}!-d
RewriteRule ^(。*)$ index.php?/ $ 1 [L]
< / IfModule>

< IfModule!mod_rewrite.c>
#如果我们没有安装mod_rewrite,所有404的
#都可以发送到index.php,一切正常。
#提交者:ElliotHaughin

ErrorDocument 404 /index.php
< / IfModule>


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

I have htaccess

RewriteEngine On
RewriteBase /

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

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

解决方案

Give this a shot (taken from the 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> 

这篇关于代码点击器 - URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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