aws-samples / eb-php-wordpress

Configuration files and instructions for installing WordPress securely and running it in a load balanced AWS Elastic Beanstalk environment with an EFS file system for shared assets.
Apache License 2.0
165 stars 95 forks source link

Permalinks do not work #27

Open GuerrillaCoder opened 3 years ago

GuerrillaCoder commented 3 years ago

Permalinks do not work with this config. How do I set the nginx re-write rules?

bunnmv commented 3 years ago

I faced the same issue and eventually I was able to solve it following these 2 steps.

1 - New Location Rule:

New NGINX Location rule

location / {
    try_files $uri $uri/ /index.php?$args;
}

2 - How to edit the NGINX location rules:

Configure NGINX with .ebextensions

Place that script in a new file located in .platform/nginx/conf.d/elasticbeanstalk, I named mine permalink.conf

.platform
    nginx
         conf.d
             elasticbeanstalk
                 permalink.conf

Optitional - Elementor Fix

After using the new location rule I was still facing issues with Elementor.

Elementor Fix

Replacing permalink.conf with the following code fixed it.

location /{
    try_files $uri $uri/ /index.php$is_args$args;
}

Final permalink.conf code :

#pemalink fix

# Enable WordPress Permalinks Support (default .htaccess replacement)
# .platform/nginx/conf.d/elasticbeanstalk/permalink.conf
location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

Hope these work!