简体   繁体   中英

Codeigniter urls working with index.php and also without index.php

I changed my config and replaced it with

$config['index_page'] = '';

here is .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

but the issue is that both of my url's are working, I want that it should only work without index.php

https://www.example.com/index.php/example/xyz-abc

https://www.example.com/example/xyz-abc

Please try with below code it may help you.

config.php file

$config['index_page'] = ""
$config['uri_protocol'] = "REQUEST_URI"

.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]

Please try with below code it's working fine. Rewrite your .htaccess file with below code.

RewriteEngine on

RewriteBase /

RewriteCond $1 !^(index.php|assets|artwork|adminAssets|galleryAssets|html|cache)

RewriteRule ^(.*)$ /index.php/$1 [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