I am trying to set up magento 2 in a subdirectory via nginx ? i want my url to be
http://mywebsite.com/shop/
If I run my website with base url : http://mywebsite.com/
.It works but when I add /shop/ it doesn't. I have tried a lot many things but still not able to figure out.
FYI : I am not trying to make a store here as other stack overflow solutions have suggested. I just want the subdirectory path in the url. Also I am using the nginx.conf.sample
I kept mostly everything same in nginx.conf but with this addition :
location /shop {
try_files /shop/pub /shop/pub /index.php$is_args$args;
}
and
location /shop/static/ {
# Uncomment the following line in production mode
# expires max;
# Remove signature of the static files that is used to overcome the browser cache
location ~ ^/shop/static/version {
rewrite ^/shop/static/(version[^/]+/)?(.*)$ /static/$2 last;
}
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ {
add_header Cache-Control "public";
add_header X-Frame-Options "SAMEORIGIN";
expires +1y;
if (!-f $request_filename) {
rewrite ^/shop/static/?(.*)$ /static.php?resource=$1 last;
}
}
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
add_header X-Frame-Options "SAMEORIGIN";
expires off;
if (!-f $request_filename) {
rewrite ^/shop/static/?(.*)$ /static.php?resource=$1 last;
}
}
if (!-f $request_filename) {
rewrite ^/shop/static/?(.*)$ /static.php?resource=$1 last;
}
add_header X-Frame-Options "SAMEORIGIN";
}
The static resource loads fine but the page is giving me 404 error. Don't understand what might be the issue here ?
core_config
table for the URL of your website? OR did you tried to change it from the backend configuration section?