Welcome Guest, Not a member yet? Register   Sign In
CI 4 remove index.php
#12

(This post was last modified: 11-08-2022, 02:22 AM by boddah85.)

(12-29-2020, 12:29 PM)InsiteFX Wrote: You can also remove it by using .htaccess in the root with index.php by adding this
to the .htaccess file.

Code:
   # Remove index.php from URL
   RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$
   RewriteCond %{THE_REQUEST}      ^[^/]*/index\.php [NC]
   RewriteRule ^index\.php(.*)$     $1 [R=301,NS,L]

Thanks, it helped in almost all cases. However i have a problem with one client. When im trying domain.com/index.php/page/1 it correctly returns domain.com/page/1. But when im trying domain.com/index.php it redirects to domain.com/var/www/domain.com/public  Huh

My htaccess
Code:
# Disable directory browsing
Options All -Indexes

# ----------------------------------------------------------------------
# Rewrite engine
# ----------------------------------------------------------------------

# Turning on the rewrite engine is necessary for the following rules and features.
# FollowSymLinks must be enabled for this to work.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

# If you installed CodeIgniter in a subfolder, you will need to
# change the following line to match the subfolder you need.
# http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
# RewriteBase /

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

RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Rewrite "www.example.com -> example.com"
# RewriteCond %{HTTPS} !=on
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [R=301,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 the front controller, index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

# Remove index.php from URL
RewriteCond %{HTTP:X-Requested-With}    !^XMLHttpRequest$
RewriteCond %{THE_REQUEST}              ^[^/]*/index\.php [NC]
RewriteRule ^index\.php(.*)$            $1 [R=301,NS,L]

# Ensure Authorization header is passed along
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</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 index.php
</IfModule>

# Disable server signature start
    ServerSignature Off
# Disable server signature end
Reply


Messages In This Thread
CI 4 remove index.php - by nurgaleevarman - 12-07-2020, 01:38 AM
RE: CI 4 remove index.php - by captain-sensible - 12-07-2020, 01:21 PM
RE: CI 4 remove index.php - by demyr - 12-08-2020, 02:16 AM
RE: CI 4 remove index.php - by nurgaleevarman - 12-28-2020, 09:44 PM
RE: CI 4 remove index.php - by CsurveyVN - 03-14-2022, 12:34 AM
RE: CI 4 remove index.php - by paliz - 12-08-2020, 09:29 AM
RE: CI 4 remove index.php - by InsiteFX - 12-29-2020, 12:29 PM
RE: CI 4 remove index.php - by boddah85 - 11-08-2022, 02:11 AM
RE: CI 4 remove index.php - by thinkstartpl - 01-26-2021, 11:51 PM
RE: CI 4 remove index.php - by Jalapeno - 02-07-2022, 06:59 AM
RE: CI 4 remove index.php - by ClaudeSjDevinHenry - 03-03-2022, 04:44 AM
RE: CI 4 remove index.php - by Kenn38 - 03-03-2022, 09:39 PM
RE: CI 4 remove index.php - by ikesela - 11-08-2022, 06:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB