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 require 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.
Using X-Cart versions 5.3.1 and earlier, enabling mod_rewrite will enable the "Enable clean URLs" button in the Environment section of the store's Admin area.
IIS Setup
To set up your IIS, use the Import of Apache rules feature. Follow the guidelines provided in the article http://www.iis.net/learn/extensions/url-rewrite-module/importing-apache-modrewrite-rules and import the controls from your <X-Cart>/.htaccess
file.
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.0 and later
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).
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:
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 theweb_dir
variable in the<X-Cart>/etc/config.php
file.Make sure that the AllowOverride directive is set to All in the conf.httpd file on your server:
AllowOverride All
Related pages: