Reputation: 1007
I am using the default .htaccess file of opencart below, I manually added the last 2 lines.
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]
RewriteCond %{REQUEST_URI} diger_olcu_aletleri
RewriteRule ^diger_olcu_aletleri$ http://www.hirdavatdeposu.com/diger-olcu-aletleri
I have checked using the website (http://htaccess.madewithlove.be/) and it changes my url
diger_olcu_aletleri
to
diger-olcu-aletleri
as expected, however it does not work in my website. What can be the problem ?
Below is my complete .htaccess file.
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess.
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini|log)">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [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]
RewriteCond %{REQUEST_URI} diger_olcu_aletleri
RewriteRule ^diger_olcu_aletleri$ http://www.hirdavatdeposu.com/diger-olcu-aletleri
### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off
# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M
# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M
# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200
# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200
Upvotes: 1
Views: 2755
Reputation: 659
We had a different issue where OpenCart SEO Urls weren't being displayed. All Google searches pointed us to enabling mod_rewrite. The solution to our problem was slightly different than what others have posted, so I thought I would share in a place that others might find as well.
Our platform:
-Linux version 2.6.32-042stab111.11
([email protected]) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Tue Sep 1 18:19:12 MSK 2015-CentOS release 6.8 (Final) -Kernel \r on an \m
Service provider: railsplayground.com
We correctly created our .htaccess file as OpenCart specifies cp .htaccess.txt .htaccess
But this broke all pages that OpenCart showed us.
After much gnashing of teeth, we started to comment out different lines in the .htaccess file.
It turned out the first line
Options +FollowSymlinks
Broke our links. Removing this line entirely made the SEO URLS work just fine.
Also, be sure not to have a / either before or after the SEO URL.
Hope this helps someone out.
Upvotes: 0
Reputation: 15151
The last line of the OpenCart .htaccess
rules basically catches anything and then stops. Try your two lines just after the RewriteBase
line as that should work. The .htaccess
file is checked line by line and the L
in [L,QSA]
on the last OC line means to stop after that line is run
Upvotes: 3