NGINX Rewrite Rules Setup
avatar
Señor FAQ

¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.


How to Set Up Nginx Rewrite Rules for JScms

To ensure JScms works correctly with Nginx and provides SEO-friendly URLs, rewrite rules must be configured. These rules route requests to the correct files and handle custom error pages.

Where to Configure the Rewrite Rules?

The rewrite rules must be added to your Nginx server configuration file. There are two locations to configure:

  • The root directory of your JScms installation.
  • The /admin/ directory for the administrator panel.

Nginx Rewrite Rule Configuration

Add the following configuration inside your Nginx server block:

Root Directory

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

Admin Directory

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

Explanation of the Rules

  • try_files $uri $uri/: First checks if the requested file or directory exists.
  • /index.php?$args: If no file or directory is found, the request is forwarded to index.php with query string parameters.

Troubleshooting

  • Ensure that the Nginx configuration file is properly reloaded using sudo systemctl reload nginx.
  • Check the Nginx error logs for any configuration issues.
  • Make sure PHP is correctly installed and running on your server.
Was this article helpful?
0 out of 0 found this helpful