One of the most popular, repeated questions asked on this forum is in regards to SEF issues causing 404 and 500 page errors.
The first thing to do is identify that this error is in fact due to turning on SEF. Since this thread will be about SEF issues, please verify that your site links in question work fine with SEF off (Disable your Joomla SEF, and or your component SEF).
---------------------------------
1. The most common issue I see is the incorrect usage of VM component links in Joomla menu systems.
Symptoms: - 404 page
- redirects to VM category or product pages
- other redirect issues
For SEF to work properly, and for Joomla module assignments in VM, you need to have a primary/master link to VM component. When you first set up Virtuemart, you should assign it a menu link in a Joomla Menu.
Typically you may name this link "Shop" or "Store", though you can name it whatever you want to. Make sure you assign it an alias (no spaces, lowercase).
If you have not done this, or did not do this before you created Joomla menu links to category and/or product pages, then you likely will have problems.
Never created a Joomla menu link to VM component: If you never create a link to VM component in Joomla, then VM assigns itself an Itemid of 1. Joomla uses Itemid's to assign modules. In other words, to assign modules, you need to have a menu item to assign it to! Not having a link to VM in Joomla menu system will not give you any control over your modules you may want to assign to VM pages. Likewise, when you turn on SEF, you likely will encounter redirect issues during checkout, since having an itemid is crucial to the redirect process. All you need to do is create a Joomla menu link to the VM component.
Do not fill in any of the parameter values for the menu item. You can now turn on your SEF and test again!
I did create a Joomla menu link to VM component: If you have created one or more Joomla menu link(s) to the VM component, then likely you did this before creating a primary/master link to VM component. Essentially Joomla will only use ONE Itemid for Virtuemart component. This Itemid is considered to the the ROOT of your store to Joomla with SEF on. To troubleshoot, you will first need to find WHAT ITEMED is Joomla using as your VM primary/master Itemid.
a. Turn your SEF off.
b. Create a Joomla article page, and enable the Virturemart Module to show on that page, with the "Show All Products" enabled.
c. Click on the "Show All Products" link in module on the article page.
d. In the URL of "Show All Products" you will see an Itemid. This itemid is what Joomla is using as your store root.
e. Go to your Joomla menu Manager and find this id number in your Joomla menus.
f. Take this link and:
- rename it to "Store" or "Shop" (or whatever your want to signify as your store root)
- move this link to a Main Level menu item, if it is not already
- Remove any/all parameters assigned to the VM component menu item (parameters on right of menu item when editing)
- If this link was a category or product page link, you will need to create a new one.
What you have done is now found your master Itemid for VM, and labeled this as store/shop/etc, and put it on a main/top level in your menu, with no VM parameters assigned.
You should be able to turn back on your SEF and see everything like your categories and products, checkout, etc, are under your Joomla assigned VM root of yoursite.com/store/ or yousite.com/shop/ or similar.
---------------------------------
2. Your template is not developed correctly.
Symptoms: - 500 error pages
- Add to cart button not working with SEF on
While I cannot help you with your template, you can easily find out if it's a template issue. With SEF on, change your Joomla template to a template provided in the Joomla installation package, like BEEZ. If you find that your 500 errors are gone, then it is a template design/architecture issue, and you should contact your template developer.
---------------------------------
3. You are using a 3rd party SEF component.
Symptoms: - 500 error pages
- 404 error pages
- other redirect issues
I cannot help you at all with 3rd party SEF if these other solutions posted here do not help. You best bet is to contact the SEF developer directly (on their forum or email) for a solution.
---------------------------------
4. Your domain name repeating in URL (dup domains).
Symptoms: - 500 error pages
- domain.comdomain.com/index.php...
You did not put a trailing slash "/" in the URL settings of your VM config. Please make sure both URL and Secure URL settings have a trailing slash. IE:
http://www.domain.com/---------------------------------
5. Lack of www in domain names.
Symptoms: - Add to cart button not working SEF on and AJAX.
Set your VM URL settings (in VM admin) to use www in the domain. Likewise, you can use .htaccess to force the use of www on non-www requests.
Add this code at bottom of .htaccess, for both http, https:
###### Added by Forrest to insure AJAX cart works by force of www
#
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS} =on
RewriteRule .*
https://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS} !=on
RewriteRule .*
http://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
#
########## End - Addition by Forrest
If you want to specify ONE domain or BY domain instead use this:
Note: make sure you repalce "YOURDOMAINHERE" with your domain name without www.
###### Added by Forrest to insure AJAX cart works by force of www
#
RewriteCond %{HTTP_HOST} ^YOURDOMAINHERE\.com
RewriteCond %{HTTPS} =on
RewriteRule .*
https://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^YOURDOMAINHERE\.com
RewriteCond %{HTTPS} !=on
RewriteRule .*
http://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
#
########## End - Addition by Forrest
---------------------------------
6. .htaccess is not set up correctly when your site is in a sub folder.
Symptoms: - Complete lack of functioning site.
- 404 pages
If you just turned on SEF, and renamed htaccess.txt to .htaccess, then you will want to turn on mod_rewrite and also specify the sub-folder in which your installation sits. To turn them on, just uncomment them (remove "#")
# mod_rewrite in use
RewriteEngine On
RewriteBase /yoursubfolder
---------------------------------
7. router.php and custom VM hacks
Symptoms: - 404 pages
- redirects to incorrect VM pages
If you are using router.php, and problem 1 in this post did not solve your issue, then you may have a hack installed that the router.php was not designed to handle. Router.php was designed with specific VM pages, native to VM. If you add new functions to VM using hacks, then router.php will not know how to handle these new functions and pages. You will need to modify router.php to support them. Likewise, router.php has a few known issues, like a redirect issue during checkout when adding new shipping addresses, and I believe also with "Ask a Product Question".
---------------------------------