2016-03-15 51 views
0

刪除的index.php我有一個叫做「笨」(非常原始的),所以我參觀這個地址,它加載罰款文件夾下我的笨庫,http://mysite.co.uk/codeigniter/index.php/pages/view/about代碼點火器不能從URL

不過,我可以」 t使用以下地址http://mysite.co.uk/codeigniter/pages/view/about到達我的'about'頁面,該地址中沒有'index.php',它會一直打到我的默認控制器而不是我的頁面控制器。

$config['base_url'] = 'http://mysite'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'REQUEST_URI'; 

的.htaccess

RewriteEngine on 
RewriteBase /codeigniter/ 
RewriteCond $1 !^(index.php|resources|robots.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

的config.php任何幫助將是巨大的:

我已經更新了以下!

+0

製作'$配置使用[ 'BASE_URL'] =「HTTP本';'爲'$ config ['base_url'] ='http:// mysite /';' - 通知結束斜線。它由[docs]提出(https://github.com/bcit-ci/CodeIgniter/blob/develop/application/config/config.php#L10)。其次,嘗試使用'RewriteRule ^(。*)$ index.php?/ $ 1 [L,QSA]' - 注意問號(某些服務器需要修復)。最後但並非最不重要的是,重定向可能是'APPPATH'的問題。 'routes.php'',也許? – Tpojka

+0

感謝您的回覆。我已經嘗試了前兩個建議,但仍然沒有運氣。 APPPATH是什麼意思?應該做什麼改變? –

+0

'APPPATH'是你的'/ codeignter/application /'目錄的'CI'常量,所以我犯了錯誤,我的意思是'APPPATH。 'config/routes.php'文件。只是在問自己是否有可能導致你描述的那種方式。 – Tpojka

回答

0

確保將「AllowOverride All」放置在您的Apache配置文件中,以便使.htaccess工作。 // mysite的:

+0

我在哪裏可以找到我的Apache配置文件?我對PHP非常陌生我是一個Python開發人員,通常是 –

+0

它位於conf目錄下的Apache安裝目錄中。你應該能夠看到httpd.conf。這是Apache的主要配置文件。尋找AllowOverride,然後重新啓動Apache服務。 – quetzalcoatl

0

你可以在你的.htaccess

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$0 [PT,L] 
0

你可以在你的.htaccess文件

Options -Indexes 
<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteCond $1 !^(index\.php|resources|robots\.txt) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
     #RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost [NC] 
     #RewriteCond %{HTTP_REFERER} !^http://(www\.)?localhost.*$ [NC] 
     #RewriteRule \.(jpe?g|gif|bmp|png)$ - [F] 
</IfModule> 
#Gzip 
<ifmodule mod_deflate.c> 
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript 
</ifmodule> 
<IfModule mod_headers.c> 
Header add Cache-Control: "no-store, no-cache, must-revalidate" 
Header unset Pragma 
FileETag None 
Header unset ETag 
</IfModule> 
#End Gzip 
# BEGIN Expire headers 
<ifModule mod_expires.c> 
    ExpiresActive On 
    ExpiresDefault "access plus 5 seconds" 
    ExpiresByType image/x-icon "access plus 2592000 seconds" 
    ExpiresByType image/jpg "access plus 2592000 seconds" 
    ExpiresByType image/jpeg "access plus 2592000 seconds" 
    ExpiresByType image/png "access plus 2592000 seconds" 
    ExpiresByType image/gif "access plus 2592000 seconds" 
    ExpiresByType text/x-javascript "access 1 month" 
    ExpiresByType text/html "access plus 600 seconds" 
    ExpiresByType text/css "access plus 604800 seconds" 
    ExpiresByType text/javascript "access plus 216000 seconds" 
    ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" 
    ExpiresByType application/pdf "access 1 month" 
    ExpiresByType application/javascript "access plus 216000 seconds" 
    ExpiresByType application/x-javascript "access plus 216000 seconds" 
    ExpiresByType application/xhtml+xml "access plus 600 seconds" 
</ifModule>