简体   繁体   中英

Codigniter htaccess error 404 at production

i am very begainer to server technologies.i know this question asked too many times but i really don't get it run. it runs with
domain.com/2.0/index.php/test
but when you remove index.php it throws

The requested URL /2.0/test was not found on this server. Apache/2.2.15 (CentOS) Server at domain.com port 443

my project stucture
在此处输入图片说明 -
Public_html
--2.0(this is my project folder where ci can be located.it has sys,app,.htaccess)
--.htaccess

My domain
https://domain.com/2.0/

about the problem
i have two htaccess one at root mention above one is inside 2.0 folder
and the strange thing is what ever i write in the htaccess file it never effect anything

public_html/.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

public_html/2.0/.htaccess

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

my httpd.conf

<VirtualHost *:443>
    ServerAdmin info@domain.com
    DocumentRoot /home/natural/public_html
    ServerName api01.domain.net
    ErrorLog /var/log/httpd/error_log
    CustomLog /var/log/access_log common

    SSLEngine on
    SSLCertificateFile /home/natural/api01.domain.net.crt
    SSLCertificateKeyFile /home/natural/api01.domoin.key

    <Directory />
    Options Indexes FollowSymLinks
        Allow from all
        AllowOverride None
    </Directory>
</VirtualHost>

i search alot and follow all the answers by Stack overflow but no luck.

The directive "AllowOverride None" in httpd.conf will disable parsing of the .htaccess file within the directories specified (in this case /) -- Can you confirm that either of your .htaccess files are in fact being parsed?

If not, does modifying the Directory subsection within your httpd.conf file to:

<Directory />
Options Indexes FollowSymLinks
Allow from all
AllowOverride All
</Directory>

Solve the issue?

For more information: http://httpd.apache.org/docs/2.4/mod/core.html#allowoverride

I assume 2.0 is the new version of the site. It looks like /2.0/.htaccess is written as though it expects to be in the root folder. Try adding RewriteBase /2.0/ after engine on. You can remove it later when you replace the contents of the root folder with that of 2.0 's.

The main problem is your # Handle Front Controller... rule. It'll capture any virtual URLs before they ever get to the 2.0 folder. Try changing it to this:

RewriteRule ^(?!2\.0(?:/|$)) index.php [L]

That will exclude the 2.0 folder from the current site's virtual URLs.

You do still need AllowOverride all as recommended by the other answer, and the directory should be the same as your DocumentRoot , not / .

Add this code inside root->.htaccess file

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM