我在根域(domain.com/)上运行的Laravel应用和(domain.com/wordpress /)上的WordPress网站。
Laravel app的根文件夹= / var / www / laravel-application /
WordPress的根文件夹= / var / www / wp /
Laravel和WordPress一切正常,直到我在WordPress中打开漂亮的永久链接。我收到了Laravel错误页面' NotFoundHttpException'。似乎Laravel正在干预WordPress的重写。
这是我的Nginx配置:
server {
listen 80;
listen [::]:80 ipv6only=on;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
root /var/www/laravel-application/public;
index index.php index.html index.htm;
server_name domain.com www.domain.com;
location /wordpress {
alias /var/www/wp;
location /wordpress {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.well-known {
allow all;
}
}
我几乎尝试过其他主题的所有建议,但没有成功。没有插件/主题,只是基本的WordPress安装。到目前为止,我能够使用普通网址在Word别名文件夹中使用WordPress。
我无法弄清楚为什么在别名文件夹中Laravel路由仍然会在网址重写上获取请求。
我在这里做错了什么?
答案 0 :(得分:0)
我认为你应该尝试在config


 location / {
 try_files $ uri $ uri / /index.php?$args;
}
我已将此添加到我的nginx和它工作

答案 1 :(得分:0)
我自己通过this coding magician的配置修复了它。