Folder and file structures
public_html/
web/index.php
upload/img.jpg
I need mysite.com/web/index.php to become mysite.com/index.php This is my htaccess
RewriteEngine On
RewriteRule ^$ web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ web/$1
it works perfectly for me. but i can't access directory "upload/img.jpg" anymore. can i still access mysite.com/upload/img.jpg ?
Thank you in advance for your time.
Kind regards.
You can try this rule instead:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !^(web|upload) web%{REQUEST_URI} [L,NC]
This will skip this rule if requested URI is for /web/
or /upload/
Now I can answer my question.
This is .htaccess in folder /public_html/
RewriteEngine On
RewriteRule ^$ web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ web/$1
and this is .htaccess in folder /public_html/web/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^uploads/(.*) /uploads/$1 [PT]
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.