2009-09-27 47 views
0

Codeinginter提供.htaccess文件,如下所述。它從CI User Guide如何修改.htaccess,使其指向codeigniter中的子文件夾

但是,當我在xampp/htdocs/mycodeigniter中添加此文件並指向http://127.0.0.1/mycodeigniter/somepage時,它將轉到http://127.0.0.1/xampp這是htdocs中的根文件。

如何修復該文件使其指向http://127.0.0.1/mycodeigniter/somepage

++++++++++++

默認情況下,index.php文件將被包含在你的URL: example.com/index.php/news/article/my_article

您可以通過使用帶有一些簡單規則的.htaccess文件輕鬆刪除此文件。下面是這樣一個文件的一個例子,使用「負」的方法中,一切都被重定向除指定的項目:

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 

在上述例子中,比那些的index.php,圖像之外的任何HTTP請求時,而robots.txt被視爲您的index.php文件的請求。

回答

2

嘗試相對替代路徑:

RewriteCond $1 !^(index\.php|images|robots\.txt) 
RewriteRule ^(.*)$ index.php/$1 [L] 
1

您可能也想從重定向

排除的CSS和JavaScript的文件替換此:的RewriteCond $ 1→(index.php文件|圖片| robots.txt) 有了這個:RewriteCond $ 1!^(index.php | images | robots.txt | stylesheets | javascript)

相關問題