php - Permalinks in Wordpress not working with Laravel + Nginx -
i have site developed laravel on main route www.example.com/. have configured nginx , php-fpm. config below.
then added blog in route /blog (www.example.com/blog/) , configured nginx alias.
now problem permalinks in wordpress not working. nginx redirects laravel's 404 page.
for example when user enters url this: example.com/blog/about, laravel's 404 page shows weird.
how can fix this? how can config nginx? what's wrong?
server { listen 80; server_name example.com; root /usr/share/nginx/html/; location /blog { try_files $uri $uri/ /index.php?$args; alias /usr/share/nginx/blog/; index index.php index.html index.htm; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param script_filename /usr/share/nginx$fastcgi_script_name; } } location / { root /usr/share/nginx/main_site; index index.php index.html index.htm; try_files $uri $uri/ /index.php$is_args$args; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } } }
you not need use alias when location matches end of alias path. see this document.
the try_files in location /blog needs default wordpress router (/blog/index.php) , not laravel router (/index.php).
try:
location /blog { try_files $uri $uri/ /blog/index.php?$args; root /usr/share/nginx; ... location ~ \.php$ { ... fastcgi_param script_filename $document_root$fastcgi_script_name; } }
Comments
Post a Comment