WordPress blog subdirectory with Laravel on nginx produces 404 error
I installed a new WordPress blog thru Forge onto the same server as a Laravel 5.4 app. I put the blog in blog.example.com
for simplicity sake, but I don’t have any DNS actually pointing to the subdomain. Instead, I want to have example.com/blog
pointing to my WordPress installation.
I then modified the nginx conf file for the Laravel site to look like this:
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/before/*;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
root /home/forge/example.com/current/public;
# FORGE SSL (DO NOT REMOVE!)
ssl_certificate /etc/nginx/ssl/example.com/230815/server.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/230815/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'SHA-HASH-HERE';
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/server/*;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/example.com-error.log error;
error_page 404 /index.php;
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
fastcgi_connect_timeout 600;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
}
location ~ /.(?!well-known).* {
deny all;
}
location /blog {
root /home/forge/blog.example.com/public;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
access_log /var/log/nginx/blog.example.com-access.log;
error_log /var/log/nginx/blog.example.com-error.log error;
}
}
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/after/*;
I restarted nginx expecting to see the WP installation when I visit example.com/blog
but instead I only see a 404 error from the Laravel app.
What is wrong with my approach here?
from Laravel Questions and Answers https://laravelquestions.com/laravel/wordpress-blog-subdirectory-with-laravel-on-nginx-produces-404-error/
via Lzo Media
Nice it seems to be good post It will get readers engagement on the article since readers engagement plays an vital role in every with Php expert
ReplyDelete