1

I am trying to make friendly urls, all the urls are working absolutely fine just 1 url is not working. I want

http://example.com/checkout/cart 

to display the page from

http://example.com/index.php?route=checkout/cart

I tried lots of solutions but none of them was working.

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^checkout/cart /index.php?route=checkout/cart [L]
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

Please Help, Thanks in Advance.


After trying lots of code, the Latest Htacces file has the following code

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]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteRule ^(.*)/cart/? /index.php?route=checkout/checkout [L]
RewriteRule ^cart/? /index.php?route=checkout/cart [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]

There is no htaccess file in the sub directories, neither in checkout folder

Thanks :)

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Originally read that as "sex friendly url"... which probably says more about me than it does about the question... but since SEO and URL are abbreviations they should probably be capitalized. – Parthian Shot Jul 23 '14 at 20:19
  • What is the problem when you visit `http://example.com/checkout/cart` in the browser? – anubhava Jul 23 '14 at 21:06
  • @anubhava it gives me 404 not found error, when i visit http://example.com/index.php?route=checkout/cart it shows me the correct page – Innocent Devil Jul 24 '14 at 04:45
  • Is `/checkout/` a directory? – anubhava Jul 24 '14 at 06:48
  • @anubhava yes, its a directory where file named cart is saved. I recently tried two more rules just before the rewrite condition --- `RewriteRule ^(.*)/cart/? /index.php?route=checkout/cart [L] RewriteRule ^cart/? /index.php?route=checkout/cart [L] which resulted in reaching the destination with incorrect url `(http://example.com/cart3)` rest all the urls are giving 404 error – Innocent Devil Jul 24 '14 at 06:57
  • Ok can you post your full latest .htaccess in question. Also is there any .htaccess inside `/checkout/` folder? – anubhava Jul 24 '14 at 06:58
  • @anubhava thanks buddy for replying. I have added the latest htaccess code in the question. There is no htaccess file in checkout folder. Thanks again :) – Innocent Devil Jul 24 '14 at 08:30
  • As per your rules you're rewriting `http://example.com/checkout/cart` to `/index.php?route=checkout/checkout` is that correct? – anubhava Jul 24 '14 at 08:50
  • @anubhava i want to open the same page by following both the urls, presently it was working as `/index.php?route=checkout/cart`. After making friendly urls the url changed to `http://example.com/checkout/cart`, but it gives me 404 error. While using the old url, it opens the page without any errors. – Innocent Devil Jul 24 '14 at 09:37

2 Answers2

1

Have your .htaccess like this:

Options +FollowSymlinks -MultiViews

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

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^sitemap\.xml$ index.php?route=feed/google_sitemap [L,QSA,NC]
RewriteRule ^googlebase\.xml$ index.php?route=feed/google_base [L,QSA,NC]
RewriteRule ^download/(.*)$ /index.php?route=error/not_found [L,QSA,NC]
RewriteRule ^checkout/cart/? /index.php?route=checkout/cart [L,QSA,NC]

RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^/]+)/?$ index.php?_route_=$1 [L,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

You probably just want a single rule. Note that RewriteCond's only apply to the immediately following RewriteRule, so the second rule that you have has no conditions.

Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?route=$1 [L,QSA]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • Thanks for replying, it is giving me 404 not found error for the homepage – Innocent Devil Jul 24 '14 at 04:48
  • i used htaccess for more urls and they are working fine, i show you the complete code `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]` – Innocent Devil Jul 24 '14 at 04:59