Skip to main content
All CollectionsStore SetupSEO & Analytics
SEO-Friendly URLs: Server Setup & Troubleshooting
SEO-Friendly URLs: Server Setup & Troubleshooting

Learn how to configure the server to support SEO-friendly URLs.

Olga Tereshina avatar
Written by Olga Tereshina
Updated over a week ago

Before using SEO-friendly URLs in your online store, you must ensure the server is configured correctly and supports the required URL format. You may need a different setup depending on your server software. This article describes how you can set up Apache, IIS, or Nginx.

Apache Setup

You need to enable Apache's module mod_rewrite.

Typically, it would be best if you edited the httpd.conf file of your Apache and replace the following line in it:

#LoadModule rewrite_module modules/mod_rewrite.so

with the next one:

LoadModule rewrite_module modules/mod_rewrite.so


After replacing the line, as shown above, restart your Apache server and check the results.

In X-Cart v5.3.1 and earlier, enabling mod_rewrite will enable the "Enable clean URLs" button in the Environment section of the store's Admin area.

Nginx Setup

To set up Nginx, you will need to add a few lines (as provided below) into the server {} section of your Nginx configuration file (nginx.conf):

Configuration for X-Cart 5.4.x and X-Cart 5.5.x

Starting from X-Cart v5.4.0.0, the software package contains an nginx.conf.sample file that provides the code samples of Nginx configuration for the possible X-Cart locations (a web-root folder or a web-root subfolder).

X-Cart 5.5.x software package also contains an nginx.conf.sample file that you can use similarly. You can also refer to the nginx.conf.webdir-sample file if you host your store in a folder other than the public dir.

Configuration for X-Cart 5.3.2 and later

Starting from X-Cart 5.3.2, you must change the configuration to accept dots(.) in the URL path.

## Example nginx configuration (X-Cart 5.3.2+) 
location @handler {
index cart.php;

rewrite ^/sitemap.xml(\?.+)?$ /cart.php?target=sitemap;
rewrite ^/((?!images/|files/|var/theme/images/).*)$ /cart.php?url=$1 last;
}

location / {
try_files $uri $uri/ @handler;
}

location ~ \.php$ {
try_files $uri @handler;
# be careful about your fastcgi params, don't let duplicate try_files
}

If your X-Cart installation is placed in your web-root subfolder, you should define the corresponding folder as a location.

Configuration for X-Cart 5.3.1 and earlier

## Example nginx configuration 
location / {
index cart.php;

if (!-e $request_filename){
rewrite ^/sitemap.xml(\?.+)?$ /cart.php?target=sitemap;
rewrite ^/((([/_A-Za-z0-9-]+)/)?([_A-Za-z0-9-]+)/)?([_A-Za-z0-9-]+)(/?)(\.([_A-Za-z0-9-]+))?$ /cart.php?url=$5&last=$4&rest=$3&ext=$7 last;
}
}


Troubleshooting

The steps below usually help to fix the problem of SEO-friendly URLs not working:

  1. Make sure that the following line in your .htaccess file reflects an actual path to your store:

    RewriteBase /


    It must be the same as the value specified in the web_dir variable in the <X-Cart>/etc/config.php file.

  2. Make sure that the AllowOverride directive is set to All in the conf.httpd file on your server:

    AllowOverride All

Related pages:

Did this answer your question?