我發現了一些關於CodeIgniter和mod-rewrite問題的相關問題,但是,我還沒有找到解決我目前遇到的問題的解決方案。在使用CodeIgniter時正確配置Mod重寫
我目前有:mywebsiteurl.netfirms.com/mywebsite/index.php/admin/login
我想實現從URL中移除的index.php,像這樣:mywebsiteurl。 netfirms.com/mywebsite/admin/login
然而,在嘗試了一些修復後,我已經在這裏StackOverflow上發現經書面here一個可愛的小導遊,我最終跌跌撞撞。
我已經修改了我的MOD-改寫爲如下所示:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(home(/index)?|index(\.php)?)/?$/[L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
# RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
# RewriteRule ^(.*)$ http://www.domain.tld/$1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
###
# 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]
# 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]
即使實現這個mod重寫後,我得到一個404如果我嘗試訪問mywebsiteurl.netfirms.com/mywebsite/admin/login,則發生錯誤。如果我去mywebsiteurl.netfirms.com/mywebsite/index.php/admin/login我能夠加載頁面就好了。
我的問題歸結爲如何正確配置我的模塊重寫代碼點火器?也許我錯過了一些設置?我對mod重寫不夠熟悉,不知道哪裏出了問題。
我還應該提到我在Code Igniter配置文件中進行了更改。
$config['index_page'] = '';
有沒有人有任何想法,我可能在做什麼錯在這裏?
在此先感謝。
你的htaccess文件在哪裏? –
我有我的htaccess文件裏面的public_html/mywebsite目錄訪問mywebsiteurl.netfirms.com/mywebsite/ – Ryan