使用mod_rewrite,xampp和windows的CodeIgniter配置

Joh*_*gen 1 php xampp .htaccess codeigniter

我是CodeIgniter的菜鸟,我正在试图找出我正在构建的应用程序的配置.我的设置有问题.

我在Windows上运行XAMPP并使用别名目录指向应用程序目录.换句话说:" http:// localhost/app_name / "指向应用程序的根目录.在我为mod_rewrite执行.htaccess之前,这一切似乎都运行良好.然后,每当我尝试去控制器时,我都会回到xampp root.

我的配置是:

目录

/app_root
/app_root/codeigniter // where code igniter is located.
/app_root/main        // where the main app is located.  It' the applications 
                      // directory cut from code igniter and renamed.
Run Code Online (Sandbox Code Playgroud)

的.htaccess

<IfModule mod_rewrite.**so**>
RewriteEngine On
RewriteBase **/app_name/**
RewriteCond %{REQUEST_URI} ^codeigniter.*
RewriteRule ^(.*)$ /index.php?/$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Run Code Online (Sandbox Code Playgroud)

的index.php

$system_folder = "@codeigniter";
$application_folder = "main";
Run Code Online (Sandbox Code Playgroud)

APP_NAME /主/配置/ config.php中

$config['base_url'] = "http://localhost/app_name/";
$config['index_page'] = "";
Run Code Online (Sandbox Code Playgroud)

APP_NAME /主/配置/ routes.php文件

$route['default_controller'] = "welcome";
Run Code Online (Sandbox Code Playgroud)

我还应该声明app_name目录是与apache根不同的驱动器的别名.

Apache Root: c:\xampp\htdocs\
App_name: d:\projects\app_name\development\
Run Code Online (Sandbox Code Playgroud)

别名是:

Alias /app_name "d:/projects/app name/development"
<Directory "d:/projects/app name/development">
  Options Indexes FollowSymLinks ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory> 
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助...如果您不介意,请"解释"您在回答代码时所做的工作.我想知道我做错了什么.如果你可以帮我这个,我会给你买啤酒(通过PayPal).这令人沮丧.

Joh*_*gen 5

成功!!

我终于设法让URL重写工作,这是一个漫长而艰辛的旅程.这是我最终的工作.请注意RewriteBase上没有反斜杠.鉴于我所读到的内容,非常有趣.感谢所有试图提供帮助的人.

# Options
Options -Multiviews
Options +FollowSymLinks

#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
RewriteBase /app_name

#Removes access to CodeIgniter 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]

#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

#This last condition enables access to the images and css
#folders, and the robots.txt file
RewriteCond $1 !^(index\.php|images|robots\.txt|css)

RewriteRule ^(.*)$ index.php?/$1 [L]
Run Code Online (Sandbox Code Playgroud)