[英]My CodeIgniter project not running on WAMP server
我在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]
網站主頁正確顯示。 但是,每當我點擊任何鏈接時,沒有鏈接正在運行服務器主頁出現在法語版本中。
只有在URL中有index.php時,項目才能在WAMP上正常運行。
例如
http://localhost/codeigniter/welcome/view (This link doesn't work)
http://localhost/codeigniter/index.php/welcome/view (Links works properly)
嘗試這個,它在任何地方工作:
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]
在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以使新設置生效。
檢查.htaccess
文件中的RewriteBase
。 它會像下面一樣
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
文件會有所不同。 否則上面的代碼將起作用。 謝謝。
嘗試這個
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]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.