WordPress в папке Laravel Public

Я хотел бы показать некоторые не очень важные страницы контента из WordPress для моего приложения Laravel.

Я установил WordPress в public/pages папка моего приложения Laravel.

Однако проблема, с которой я сталкиваюсь, заключается в том, что красивые ссылки (laravel.app/pages/sample-page) выдают 404, так как они обрабатываются laravel.

Как я могу это исправить? Я предполагаю, что это должно быть обработано в файле конфигурации nginx.

Сайт размещен на Laravel Forge, и вот файл конфигурации nginx:

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/laravel.app/before/*;

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name .laravel.app;
root /home/forge/laravel.app/public;

# FORGE SSL (DO NOT REMOVE!)
ssl_certificate /etc/nginx/ssl/laravel.app/264952/server.crt;
ssl_certificate_key /etc/nginx/ssl/laravel.app/264952/server.key;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'xxx';
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/laravel.app/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/laravel.app-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;
}

location ~ /\.(?!well-known).* {
deny all;
}
}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/laravel.app/after/*;

Заранее спасибо.

0

Решение

Я установил бы wordpress в его собственную папку за пределами проекта Laravel и использовал nginx для настройки расположения страниц
что-то вроде

location ^/pages/index.php(/.*)?$ {
fastcgi_split_path_info ^(/pages/index.php)(/.+)$;
OTHER CONFIG
}

location /pages/ {
if (!-e $request_filename) {
rewrite ^.*$ /pages/index.php last;
}
OTHER CONFIG
}
0

Другие решения

Посмотрев вокруг и попробовав несколько доступных вариантов, вот рабочая конфигурация nginx:

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/laravel.app/before/*;

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name .laravel.app;
root /home/forge/laravel.app/public;

# FORGE SSL (DO NOT REMOVE!)
ssl_certificate /etc/nginx/ssl/laravel.app/264952/server.crt;
ssl_certificate_key /etc/nginx/ssl/laravel.app/264952/server.key;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'XXX';
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/laravel.app/server/*;

location /blog/index.php(/.*)?$ {
fastcgi_split_path_info ^(/blog/index.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 1000;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
location /blog/ {
if (!-e $request_filename) {
rewrite ^.*$ /blog/index.php last;
}
try_files $uri $uri/ blog/index.php?args;
}

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/laravel.app-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;
}

location ~ /\.(?!well-known).* {
deny all;
}
}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/laravel.app/after/*;
0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector