简体   繁体   中英

How to remove index.php from CodeIgniter3 install in subdirectory with Wordpress on root?

So the title of the question was a little difficult to come up with. Here's the deal, the CI3 install is like this: www.mydomain.com.au/apps/TGPS where TGPS is the CI application. Additionally, on the root of the web folder there is a Wordpress install. My question is, what is the .htaccess setup that I need to compress the URLs from: www.domain.com/apps/TGPS/index.php/controller/function to this: www.domain.com/apps/TGPS/controller/function

At present I have this:

在此处输入图片说明

The top level .htacess is this:

# BEGIN WordPress
RewriteRule ^/apps($|/) - [L] 
# END WordPress

The .htaccess in TGPS is this:

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

and the .htaccess in application is the standard one.

Seems everything I try either breaks Wordpress, CodeIgniter or has no effect. Any help would be appreciated.

乍一看,您缺少重写基础:

RewriteBase /apps/TGPS/

Try bellow code

    RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]

Then the www to non-www:

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

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