2011-07-20 16 views
6

में codeigniter index.php को हटाने के लिए htaccess का उपयोग करना, मैं अपने सीआई यूआरएल से index.php को हटाने की कोशिश कर रहा हूं, लेकिन निर्देशों का पालन करने के बाद यह काम नहीं कर रहा है।एक उपनिर्देशिका

मेरे पास एक उपनिर्देशिका में एक कोडनिर्देशक स्थापना चल रही है। मुख्य नामक रूट कॉन्फ़िगरेशन में एक डिफ़ॉल्ट नियंत्रक सेट होता है, और 'निर्माण' नामक एक और नियंत्रक होता है। डिफ़ॉल्ट ठीक चलाता है, लेकिन 324 त्रुटि देता है जो कोई डेटा प्राप्त नहीं करता है। मेरा htaccess इस तरह दिखता है:

<IfModule mod_rewrite.c> 

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 

</IfModule> 

<IfModule !mod_rewrite.c> 
    ErrorDocument 404 /index.php 
</IfModule> 
+0

आपकी अपाचे त्रुटि.लॉग का एक आउटपुट आपकी समस्या को हल करने में सहायक होगा। – Marko

उत्तर

24

यह पर्याप्त होना चाहिए:

<IfModule mod_rewrite.c> 
RewriteEngine On 

#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|public|images|robots\.txt|css) 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 
+1

में यह बहुत अच्छा काम करता था। धन्यवाद! – Robin

+0

और विजेता है ... यह। – dlopezgonzalez

+0

और stackoverflow.com/a/14807463/1537413 – Dika

7

यही वह है जो मैं उपयोग करता हूं। मेरा कोडइग्निटर भी एक उपदिर में चलता है।

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|swf|uploads|js|css|robots\.txt) 
RewriteRule ^(.*)$ /ci/index.php/$1 [L] 
+4

मैं घंटों के लिए सही mod_rewrite की तलाश में रहा हूं और यह वह है जिसने आखिरकार मेरे लिए काम किया! मुझे बस इतना करना था कि 'ci/'' mysubfolder /' –

5

.htaccess ऐड:

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

आवेदन/config/config.php में जाकर सूचकांक पेज config मान साफ़:

// Old 

$config['index_page'] = "index.php"; 

// New 

$config['index_page'] = ""; 

मेरी समस्या हल हो गई अन्य लोगों को भी आशा है .. । :)

+0

में उल्लिखित अपाचे कॉन्फ़िगरेशन को बदलने के लिए मत भूलना, मैं कोडइग्निटर उपयोगकर्ता मार्गदर्शिका से कोड का प्रयास कर रहा हूं और काम नहीं किया लेकिन अब यह जादू का धन्यवाद है सर – Belajar

+0

यह मेरे लिए काम करता है, धन्यवाद! – Robin

1

कभी कभी तुम, यह पुनर्लेखन मॉड्यूल सक्षम चलाने "apache2 मॉड्यूल पुनर्लेखन सक्षम" की जरूरत है:

sudo service apache2 restart 

:

sudo a2enmod rewrite 

आप परिवर्तनों को लागू करने वेबसर्वर फिर से शुरू करनी फिर सोफिया का जवाब फलो।

संबंधित मुद्दे