2017-11-01 1 views
0

Ich möchte einige der nicht so wichtigen Inhaltsseiten von Wordpress für meine Laravel App zeigen.Wordpress in Laravel Öffentlicher Ordner

Ich habe Wordpress in public/pages Ordner meiner Laravel-Anwendung installiert.

Das Problem, mit dem ich konfrontiert bin, ist jedoch, dass hübsche Links (laravel.app/pages/sample-page) 404 werfen, da sie von Laravel behandelt werden.

Wie kann ich das beheben? Ich gehe davon aus, dass es auf Nginx-Konfigurationsdatei behandelt werden muss.

Die Website auf Laravel Forge präsentiert, und hier ist die nginx Konfigurationsdatei:

# 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/*; 

Vielen Dank im Voraus.

Antwort

0

würde ich die Wordpress in seinen eigenen Ordner außerhalb des Projekts Laravel installieren und nginx verwenden Sie einen Speicherort für Seiten etwas wie

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

Nach etwas, und versuchen, einige der Variationen zu konfigurieren - Hier ist eine funktionierende nginx-Konfiguration:

# 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/*;