Skip to content

Instantly share code, notes, and snippets.

@decodedmrq
Last active August 24, 2023 19:42
Show Gist options
  • Save decodedmrq/7fbb4668c0e6e21c7e5412b4fa97fa97 to your computer and use it in GitHub Desktop.
Save decodedmrq/7fbb4668c0e6e21c7e5412b4fa97fa97 to your computer and use it in GitHub Desktop.
** Apache
- Edit public/.htaccess of laravel application with wordpress in subfolder
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Wordpress
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule "^(.*)$" "wordpress/$1" [L]
# End wordpress
</IfModule>
- Symbol Link wordpress from Laravel_App/public/wordpress to Laravel_App/wordpress
- Access to 127.0.0.1:8000/wordpress
@decodedmrq
Copy link
Author

ngnix

server {

listen 80;

listen 443 ssl;

server_name laravel_app.com;

root /var/www/laravel_app/public;

index index.html index.htm index.php;

charset utf-8;

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/backend-error.log error;

sendfile off;

client_max_body_size 100m;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.1-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    #fastcgi_read_timeout 300;
}

location ~ /\.ht {
    deny all;
}

# That's for wordpress
location /wordpress {
    alias        /var/www/laravel_app/wordpress;
    #try_files   $uri $uri/ @wordpress;
    error_log  /var/log/nginx/wordpress-error.log error;
    location ~\.php {
        fastcgi_pass unix:/run/php/php7.1-fpm.sock;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        #fastcgi_intercept_errors on;
    }
}

-- Frontend html
location /html {
    index links.html;
    alias /var/www/example/html;
    # autoindex on;
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment