Nasıl 'index.php' CodeIgniter'daki URL'den kaldırabilirim?

5 Cevap php

Nasıl CodeIgniter'daki index.php Benim URL adlı kaldırabilirim?

I index.php benim yapılandırma dosyasından kaldırılacak ve Apache (2.2.11) benim rewrite_module çalıştırmak ve benim .htaccess dosyası:

RewriteEngine on

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

Ben herhangi bir bağlantıyı tıkladığınızda Şimdi, bu URL bulunamadı olduğunu gösterir. Sorun nedir?

5 Cevap

Lütfen .htaccess dosyasında bu deneyin: comments sizin için tweaked yardımcı olmalıdır ...

Bu birkaç CodeIgniter web tesisatlarında mükemmel benim için çalışıyor. Mod_rewrite yüklü değilse Ayrıca, bu 404 sayfada (ya da amaca uygun olduğunu değiştirebilirsiniz) gönderecek.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #'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

    #This last condition enables access to the images and css folders, and the robots.txt file
    RewriteCond $1 !^(index\.php|(.*)\.swf|images|robots\.txt|css|docs|cache)
    RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    ErrorDocument 404 /application/errors/404.php
</IfModule>

Sanal hosts dosyasını kontrol ve set bu öğeler var olmadığını görmek - bu senin htaccess dosyası URL doğru yeniden izin verebilir.:

Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all

Bu% 100 çalışır, ben denedim. Ekle only the following in your .htaccess dosyası:

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

Ben de CodeIgniter kullanım kılavuzunda önerilen yeniden yazma kuralı ile ilgili bir sorun vardı. Ben index.php önünden çizgi kaldırarak bunu çözdü

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

Her şeyden önce, bir default controller tanımlanmış olduğundan emin olun. Sonra URLs, bunlarla ilişkili bir kontrol olduğu bir şekilde inşa emin olun. Örneğin,

Home page:

example.com/home/

Or for the About us Sayfa:

example.com/about/  

Ayrıca mod-rewrite modülü üzerinde döndü çift kontrol.

Ben de bu sorun vardı ve Shane cevabı bana yardımcı olduğunu buldu. I WAMP benim siteler kurulum var.

RewriteBase /mysite/

Apache belirtildiği gibi mysite takma adıdır. Bu benim siteler için çalıştı.