3

我在 CodeIgniter 中开发了我的项目,该项目在 XAMPP 服务器上运行完美,但在 WAMP 服务器上不运行。

我变了

$config['index_page'] = 'index.php'; to $config['index_page'] = '';

和 .htaccess 我已经

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

网站主页正常显示。但是,每当我单击以法语版本出现的任何链接 wamp 服务器主页时,都没有链接可用。

仅当 URL 中有 index.php 时,项目才能在 WAMP 上正常运行。

例如

http://localhost/codeigniter/welcome/view (This link doesn't work)
http://localhost/codeigniter/index.php/welcome/view (Links works properly)
4

4 回答 4

5

试试这个,它无处不在:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php/$1 [L]
于 2013-02-08T11:14:19.867 回答
4

httpd.conf在文件中启用 mod_rewrite

就我而言,我已经在本地磁盘 C 上安装了 WAMP

找到 httpd 文件只需导航到C:\wamp\bin\apache\apache2.2.6\conf

使用记事本编辑器打开 httpd.conf 文件,然后找到以下行:

#LoadModule rewrite_module modules/mod_rewrite.so

并取消注释

保存文件并重新启动 Apache 以使新设置生效。

于 2014-02-25T15:33:07.903 回答
0

RewriteBase.htaccess文件。就像下面

RewriteBase /your project folder name/

复制以下代码并将其粘贴到您的.htaccess文件中

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /codeigniter/



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

#RewriteRule ^page/(.*)$ index.php?/#$1 [R=301,L,NE]

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

ErrorDocument 404 /index.php;

希望它会帮助你。并检查一件事,即您的网址。如果有任何 ~ 符号,则.htaccess文件将有所不同。否则上面的代码将起作用。谢谢。

于 2013-02-08T06:19:30.493 回答
0

尝试这个

RewriteEngine On    //missed this
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
于 2013-02-08T06:23:35.027 回答