How to enable SEO URL in opencart
1.To use URL Alias you need to be running apache with mod_rewrite enabled.
sudo a2enmod rewrite
sudo service apache2 restart
2. In your opencart directory rename htaccess.txt to .htaccess.
contain of .htaccess file
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
Require all denied
</FilesMatch>
# SEO URL Settings
RewriteEngine On
RewriteBase /shop/
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Note :- In your .htaccess file, change subdirectory name. e.g. RewriteBase /shop/
If you are running opencart on localhost then url would be http://localhost/projectname. In this case RewriteBase /projectname/
Change RewriteBase according as per your project.
3. Now go to opencart admin settings page
System > settings > edit your store > under server tab enable SEO Url option
Then try to run in the browser. If there is 404 exist then follow the below step
-> Open terminal
-> Type sudo nano /etc/apache2/apache2.conf
-> Place these lines
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Now check in the browser.
Its working...!!!
Comments
Post a Comment