简体   繁体   中英

Remove app/webroot from url

I'm trying to remove app/webroot from the url in my CakePHP application using htaccess. We know it can be fixed just by pointing the vhost to the app/webroot folder, but for some reasons the developers over here prefer to fix this using htaccess.

Anyone who knows or this is possible?

Setup your various .htaccess like this:

.htaccess in DOCUMENT_ROOT:

RewriteEngine on
RewriteBase /
RewriteRule (.*) app/webroot/$1 [L]

.htaccess in DOCUMENT_ROOT/app

RewriteEngine on
RewriteBase /app/
RewriteRule (.*) webroot/$1 [L]

.htaccess in DOCUMENT_ROOT/app/webroot

RewriteEngine On
RewriteBase /app/webroot/

RewriteCond %{THE_REQUEST} \s/+app/webroot/([^\s&]*) [NC]
RewriteRule ^ /%1 [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ 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