mod_rewrite issue on VPS for unexperienced user

Jen69

Registered
Mar 19, 2013
4
0
1
cPanel Access Level
Root Administrator
Hello everyone,

I am a newbie to the VPS world and am having a bit of a problem getting my feet wet!

I have just got a VPS setup with a WHM and cPanel, uploaded an OpenCart shop that is running fine, since the latest OpenCart offers the SEO friendly URL feature, I only had to enable it in the backend and was supposed to work with the mod_rewrite enabled Apache server. Since the Apache is supposed to have the mod_rewrite enable by default, I enabled the feature in the OpenCart. Which leads me to the problem I experience when the feature is enabled.

The browser will show the friendly URL when I click on a product link, but I get the 404 error message and the product link will not load!

Looking at some other threads here, ran the command: "httpd -l | grep -i rewrite"

and the result is satisfactory:

# httpd -l | grep -i rewrite
mod_rewrite.c

Now I'm kinda lost and out of option as this is an unmanaged VPS and I get no help with it, I would appreciate any guidance and input I can get. Please keep in mind that I am novice with VPS, SSH, etc. but am a quick study and can follow directions (hopefully)

Jen
 

ThinIce

Well-Known Member
Apr 27, 2006
352
9
168
Disillusioned in England
cPanel Access Level
Root Administrator
Jen,

As well as checking the module in Apache, your opencart install will also need a line similar to the following in it's .htaccess file

RewriteEngine On

By default, the htaccess file might be named something like .htaccess.txt. - if so, knock the .txt off the end. If I remember right this should also contain the relevant rewrite rules
 

Jen69

Registered
Mar 19, 2013
4
0
1
cPanel Access Level
Root Administrator
Jen,

As well as checking the module in Apache, your opencart install will also need a line similar to the following in it's .htaccess file

RewriteEngine On

By default, the htaccess file might be named something like .htaccess.txt. - if so, knock the .txt off the end. If I remember right this should also contain the relevant rewrite rules
I removed the ".txt" from the .htaccess per OpenCart instructions, I do my best to follow directions as meticulously a possible, that's why I feel lost!
 

ThinIce

Well-Known Member
Apr 27, 2006
352
9
168
Disillusioned in England
cPanel Access Level
Root Administrator
:) Could you post the contents of your .htaccess file and let us know whether your opencart is installed in the document root of your hosting account or a sub directory?
 

Jen69

Registered
Mar 19, 2013
4
0
1
cPanel Access Level
Root Administrator
Thanks for making me to look at the right direction!!!! WOW, now I feel like DAAAAAAH!:rolleyes:

I was missing the training "/" after my directory location.... I can't belive I missed that, perhaps I needed a good night sleep and a wake-up call :)

Now that the SEO friendly URLs are working, just discovered a new issue! Since the URLs now are the product's title/name, some of the products title/name includes "/" in them, which in this case the product will not be displayed and instead the following description "The page you requested cannot be found!" is displayed! Any idea how to fix that?

By the way, thanks for the wake up call!:)

- - - Updated - - -

Here is the relevant section of the .htaccess:

# 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 /store/
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]
 

ThinIce

Well-Known Member
Apr 27, 2006
352
9
168
Disillusioned in England
cPanel Access Level
Root Administrator
That's an interesting one and may be something you want to send as a feature request to opencart, if they allow you to enter "/" into a product title name then they need to make sure these are properly encoded / escaped or dealt with in their SEO rewrite so things don't break.

If they aren't interested, then depending on how the app processes the route it may be possible to rewrite the relevant part of the request within .htaccess