please help me to complete my project its about ecommerce site in core php as i am a beginner
for my site i want seo friendly url for category, subcategory, product and product detail page….
i have pages like this :
mysite.com/category.php?category_slug=mobiles : category page
mysite.com/subcategory.php?subcategory_slug=samsung : subcategory page
mysite.com/product.php?product_slug=galaxy-note : product page
and i want to rewrite these url like this :
mysite.com/mobiles : category
mysite.com/samsung : sub category
mysite.com/galaxy-note : product page
my htaccess code is
RewriteEngine On Options -Multiviews RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9-]+)$ category.php?category_slug=$1 [NC,L] RewriteRule ^([a-zA-Z0-9-]+)$ subcategory.php?subcategory_slug=$1 [NC,L] RewriteRule ^([a-zA-Z0-9-]+)$ products.php?product_slug=$1 [L]
any help would be appreciated…
2
Answers
add page name before ^
and write your url for category page as example category/mobiles/
UPDATE
The original URL:
mysite.com/category.php?category_slug=mobiles
The rewritten URL:
mysite.com/mobiles
The original URL:
mysite.com/subcategory.php?category_slug=mobiles&subcategory_slug=samsung
The rewritten URL:
mysite.com/mobiles/samsung
The original URL:
mysite.com/products.php?category_slug=mobiles&subcategory_slug=samsung&product_slug=galaxy-note
The rewritten URL:
mysite.com/mobiles/samsung/galaxy-note
category/([a-zA-Z0-9-]+)$ category.php?category_slug=$1 [NC,L]
remove the $ sign after category/([a-zA-Z0-9-]+)