0

I have experimented a lot already. I have tried every possible combination using .htaccess file however they did not work for me, so i have to put this query for which i need very specific solutions.

No CMS is used. The website is an eCommerce site developed using php. Hosting provider is godaddy.

My site url structure is

  • For Product Pages = https://www[dot]sitename.com/product.php?product=productid
  • For Category Pages = https://www[dot]sitename.com/category.php?category=category-name
  • For SubCat Pages = https://www[dot]sitename.com/category.php?subcategory=sub-category-name

I want

  • For Product Pages = https://www[dot]sitename.com/product/productid/
  • For Category Pages= https://www[dot]sitename.com/category/category-name
  • For SubCat Pages = https://www[dot]sitename.com/category/subcategory/sub-category-name

How can i do this using php code?

anand
  • 63
  • 6
  • Have you looked at using mod_rewrite in the htaccess files? http://forums.phpfreaks.com/topic/58436-neat-url/ and http://www.sitepoint.com/guide-url-rewriting/ – ModulusJoe Oct 08 '13 at 09:32
  • Show us the rewrite code that you tried and didn't work? – anubhava Oct 08 '13 at 09:34
  • Please try this link it may be helpful http://coding.smashingmagazine.com/2011/11/02/introduction-to-url-rewriting/ – Krishnadas PC Oct 08 '13 at 09:34
  • I have used many suggestions given online and also i have asked this question and tried all suggestions given here http://stackoverflow.com/questions/19110031/rewrite-url-of-custom-php-based-e-commerce-website – anand Oct 08 '13 at 10:36

1 Answers1

0

Maybe something like this

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-s [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]

RewriteRule ^product/([0-9]+)$ product.php?product=$1 [L]
RewriteRule ^category/([a-zA-Z0-9_]+)$ category.php?category=$1 [L]
RewriteRule ^category/subcategory/([a-zA-Z0-9_]+)$ category.php?subcategory=$1 [L]
wandam
  • 162
  • 1
  • 2
  • 11
  • Yeh i tried this. As i said no .htaccess codes are working for me. May be the site is using php code to rewrite the urls so i asked to know about php code to rewrite urls. – anand Oct 08 '13 at 11:16