本文介绍了改写自定义的PHP基础的电子商务网站网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试了很多已经但是他们对我没有工作,所以我必须把这个查询,我需要非常具体的解决方案。
I have experimented a lot already however they did not work for me, so i have to put this query for which i need very specific solutions.
没有CMS被使用。该网站使用PHP开发的一个电子商务网站
No CMS is used. The website is an eCommerce site developed using php
我的网站的URL结构
- 有关产品页数=
的https:// WWW [点] sitename.com/product.php?product=productid
- 有关类别页面=
的https:// WWW [点] sitename.com/category.php?category=category-name
- 对于SubCat页=
的https:// WWW [点] sitename.com/category.php?subcategory=sub-category-name
- 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
我想
- 有关产品页数=
的https:// WWW [点] sitename.com/product/productid/
- 有关类别页面=
的https:// WWW [点] sitename.com/category/category-name
- 对于SubCat页=
的https:// WWW [点] sitename.com/category/subcategory/sub-category-name
- 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
我怎样才能做到这一点使用的.htaccess?
How can i do this using .htaccess?
推荐答案
添加到您的的.htaccess
在Web根 /
目录
Add this to your .htaccess
in your web root /
directory
RewriteEngine on
RewriteBase /
# Products
RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^product/([^/]+)/?$ product.php?product=$1 [NC,QSA,L]
# Categories
RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^category/([^/]+)/?$ category.php?category=$1 [NC,QSA,L]
# Sub-categories
RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^category/subcategory/([^/]+)/?$ category.php?subcategory=$1 [NC,QSA,L]
这篇关于改写自定义的PHP基础的电子商务网站网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!