php - 用 htaccess 重写查询字符串
问题描述
我需要重写这个网址
category.php?cat=computers
至
category/computers
或者,是不是反过来?
如何使用 .htaccess 做到这一点?
解决方案
The rule is:
RewriteRule ^category/(.+)/?$ category.php?cat=$1 [NC,L]
your .htaccess should look like this:
<IfModule mod_rewrite.c>
#if the name of the php file is the same of the path, you have to remove MultiViews
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^category/(.+)/?$ category.php?cat=$1 [NC,L]
</IfModule>
推荐阅读
- jasper-reports - Jasper 报告预览中元素的奇怪定位
- c++ - 包含 gtest.h 如何打破标准算法的模板参数推导?
- python - for循环中的Python If语句-列表索引超出范围
- sql - 如何使用具有相同外键的其他行的值更新行
- mongodb - 将 DigitalOcean Managed MongoDB 连接到 Laravel(连接错误调用 ismaster)
- redis - Redis java地图分页
- jenkins - TEST-junit-jupiter.xml 文件包含多个`
`标签,詹金斯只报告第一个 - sql - Oracle SQL中没有下限的数值之间
- java - Android Java for 循环使用较少的 CPU 并且比 C++ for 循环慢
- xml - 在 XSL 转换中附加命名空间