簡體   English   中英

無法從codeigniter網站URL刪除index.php?

[英]Can't remove index.php from codeigniter site URL?

我已經閱讀了有關刪除它的指南,他們告訴我將其添加到我的htdocs根目錄中的.htaccess中:

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

但是我的網站目錄是這樣的:htdocs \\ mywebsite \\

我嘗試在htdocs和mywebsite中都添加htaccess文件,但沒有結果。 我也嘗試將最后一行修改為

RewriteRule ^(.*)$ mywebsite/index.php/$1 [L]

在htdocs和mywebsite目錄中。 但是我不知道什么是正確的.htaccess語法或它如何工作,因此我並不真正希望它能工作。

我也嘗試在codeigniter目錄樹中的其他任何地方修改.htaccess文件。

你看過這個嗎? 如何在codeigniter的路徑中刪除“ index.php”

您是否在配置文件中更改了index_path變量? 那是application / config / config.php,版本2.1.3中的第29行

在根目錄和網站目錄中都需要有一個htaccess文件。 它們都需要包含相同的內容,只是根目錄中的文件需要更新索引的路徑以包含您的網站目錄。

根目錄:

RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ yourwebsite/index.php/$1 [QSA,L]

網站目錄:

RewriteEngine on
RewriteBase /
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]

確保您的虛擬主機條目中包含以下內容:

    <Directory "/path...to directory">
        Order allow,deny
        Allow from all
        Allowoverride all
    </Directory>

    <IfModule mod_rewrite.c>
        RewriteEngine on
    </IfModule>

除了根目錄外,您不需要修改任何.htaccess文件。 並且如上所述,請確保已在config.php文件中正確設置了所有內容。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM