我正在 Laravel 5.2 中开发网络应用程序。我有现有的 WordPress 网站。所以,我想将 Laravel 与 WordPress 集成。WordPress 应用程序具有静态页面。我的根目录中有两个单独的 Laravel 和 WordPress 目录。
- laraApp
- wpApp
我想将 wpApp 作为默认应用程序。所以当用户点击登录按钮时,用户将被重定向到 laraApp。我想要 www.example.com 上的 wpApp 和 www.example.com/laraApp 上的 laraApp。我正在运行 nginx 网络服务器。那么我的 nginx 配置文件应该是什么?
当前的 nginx 配置文件是:
server {
listen 80;
root /var/www/root/wpApp;
index index.php index.html index.htm;
server_name www.example.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# rewrite rules for laravel routes
location /laraApp {
rewrite ^/laraApp/(.*)$ /laraApp/public/index.php?$1 last;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
在这里,我的 Laravel 应用程序可以使用 url www.example.com/laraApp/public/ 访问我想使用 www.example.com/laraApp 访问它。
谢谢。