我想向我的laravel应用程序展示Wordpress中一些不那么重要的内容页面。
我已经在我的laravel应用程序的vzeroupper
文件夹中安装了Wordpress。
我面临的问题是,漂亮的链接(laravel.app/pages/sample-page)正在抛出404,因为它们是由laravel处理的。
我该如何解决这个问题?我假设它已经在nginx配置文件上处理。
该网站托管在Laravel Forge上,这是nginx配置文件:
public/pages
先谢谢。
答案 0 :(得分: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
}
答案 1 :(得分: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/*;