我想将url Category.php和Profile.php转换为url frindly,但只有类别才有效。我不想使用任何匹配的组!
示例:
domain.com/category.php?id=5
和
domain.com/profile.php?id=2
转换为:
domain.com/categoryname
domain.com/profilename
.htaccess代码:
RewriteEngine on
#category
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^/.]*)$ category.php?id=$1
#profile
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^/.]*)$ profile.php?&id=$1
但这仅适用于类别!
由于
答案 0 :(得分:0)
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^category/(\d+)*$ ./category.php?id=$1
RewriteRule ^profile/(\d+)*$ ./profile.php?id=$1
这应该有用。