I installed a custom theme on my opencart website. I sell single product and would like to redirect my customer to "product" page so when they type my web address it will take them straight there. How to do it in htaccess? Or maybe there is another way?
You don't redirect to the product.php file. You redirect to the location you see in your browser address bar when you go to the page you want the redirection to go to. Go to the page you want the redirection to go to and look at the URL that page is at. That is the location to redirect to.
Make sure you have Use SEO URLs set to Yes in your admin Settings under the Server tab. Make sure you have a SEO Keyword for your category and product.
Add this below to the bottom of your .htaccess file:
RewriteCond %{HTTP_HOST} ^(www\.)?yoursite\.com [NC]
RewriteRule ^/?$ http://yoursite.com/categoryname/productname [L,R=301]
Change the yoursite.com in both places to the URL of your site. Change the categoryname to the name of the category your product is in and the productname to the name of your product. You can also leave out the categoryname and just have the productname if you like. Now when anyone goes to your site root they will be directed to the page for your product.
Add this below to the bottom of your .htaccess file:
RewriteCond %{HTTP_HOST} ^(www\.)?yoursite\.com [NC]
RewriteRule ^/?$ http://yoursite.com/categoryname/productname [L,R=301]
Change the yoursite.com in both places to the URL of your site. Change the categoryname to the name of the category your product is in and the productname to the name of your product. You can also leave out the categoryname and just have the productname if you like. Now when anyone goes to your site root they will be directed to the page for your product.
I did everything like you told me to do and it still take me to the main webpage as always. And now when I click on the category tab it says "Not found". It looks like it was trying to find the SEO keywords.
Opencart version 3.0.3.2
You must be doing something wrong then because I tested it and it works. Do you have the default unedited .htaccess file that comes with OC and do you have mod_rewrite installed on your server? What is the URL to your product?
To answer your questions. According to godaddy my linux server comes with mod_rewrite already installed. URL to my product is: http://bow-rod.com/index.php?route=prod ... duct_id=50
Opencart version 3.0.3.2
That is not an SEO link to your product so your SEO URL's are not working. You need to have Use SEO URLs set to Yes and you need to have a SEO Keyword set for your product. You also need to have the .htaccess file renamed from .htaccess.txt to .htaccess. When you have the SEO URL's working then the addition I showed you for the .htaccess file will work.
Okay. I enabled SEO links. Added SEO keywords to "Category" and "Product".
Added this to my .htaccess and rename it from .htaccess.txt to .htaccess
"RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com [NC]
RewriteRule ^/?$ http://mywebsite.com/bowrod system/bowrod [L,R=301]"
I replaced the mywebsite.com with my web address
Now when I go to the link bow-rod.com it says:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache Server at bow-rod.com Port 80"
Added this to my .htaccess and rename it from .htaccess.txt to .htaccess
"RewriteCond %{HTTP_HOST} ^(www\.)?mywebsite\.com [NC]
RewriteRule ^/?$ http://mywebsite.com/bowrod system/bowrod [L,R=301]"
I replaced the mywebsite.com with my web address
Now when I go to the link bow-rod.com it says:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache Server at bow-rod.com Port 80"
Opencart version 3.0.3.2
Also when I type my web address it does take me to : "http://myweb.com/bowrod-system/bowrod" link but it says:
"Not Found
The requested URL /bowrod/bowrod-system/bowrod was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at bow-rod.com Port 80"
"Not Found
The requested URL /bowrod/bowrod-system/bowrod was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at bow-rod.com Port 80"
Opencart version 3.0.3.2
Your SEO URLs are not working. Did you rename the .htaccess.txt file to .htaccess and is it the default one that comes with OC?
Here is my .htaccess file :
Code: Select all
# 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.comOptions +FollowSymlinks# Prevent Directoy listing Options -Indexes# Prevent Direct Access to files<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))"> Order deny,allow Deny from all</FilesMatch># SEO URL SettingsRewriteEngine 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]RewriteRule ^download/(.*) /index.php?route=error/not_found [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]### 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# 7. disable open_basedir limitations# php_admin_value open_basedir none
RewriteCond %{HTTP_HOST} ^(www\.)?bow-rod\.com [NC]
RewriteRule ^/?$ http://bow-rod.com/bowrod-system/bowrod [L,R=301]
Opencart version 3.0.3.2
Is all the code in the .htaccess file on one line like you show there? It should look like this:
# 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 "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
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]
RewriteRule ^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]
# 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 "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
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]
RewriteRule ^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]
Yes use the one that comes with OC.
Also do you have your site in the main web folder or do you have it in a named folder in the main web folder?
It looks like you have it in a folder named bowrod and if that is the case then change this in the .htaccess file:
RewriteBase /
To this:
RewriteBase /bowrod/
Also do you have your site in the main web folder or do you have it in a named folder in the main web folder?
It looks like you have it in a folder named bowrod and if that is the case then change this in the .htaccess file:
RewriteBase /
To this:
RewriteBase /bowrod/
Who is online
Users browsing this forum: No registered users and 12 guests