【发布时间】:2014-06-22 03:25:42
【问题描述】:
我已经完成了尽职调查,花费数小时仔细研究搜索和堆栈 QA。没有骰子。所以我终于来这里寻求帮助了。
- Apache HTTP 服务器
- PHP 5.3
我的网址很脏:
.cc/store/index.php?route=checkout/cart
.cc/store/index.php?route=common/home
.cc/store/index.php?route=product/product&product_id=111
我想清理它们,这样当用户点击脏链接或输入脏网址时,他们会在地址栏中得到一个干净的网址:
.cc/store/cart
.cc/store/home
.cc/store/product/11
目前我的 htaccess 文件位于:
.cc/store/.htaccess
我知道我需要在 htaccess 中:
RewriteEngine On
但这是正确的道路吗?:
RewriteRule !/index.php?route=(A-Z)/(A-Z)&(*)$ /$2/$3
Q1:我只需要编辑 htaccess 文件还是我还必须编写一些 php?
Q2:我要编写什么 htaccess / php 代码来获得所需的干净 url?我想在浏览器的地址栏中看到干净的 url。
提前致谢。
【问题讨论】:
标签: php apache .htaccess url clean-urls