我有以下网址http://www.example.com/teams.php?team_id=12
我希望这个网址为http://www.example.com/teams-pavilion-boys-varsity-soccer
我尝试过以下代码
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^teams-([0-9a-zA-Z]+)\.html$ teams.php?team_id=$1
请帮帮我。
提前致谢
答案 0 :(得分:0)
检查出来:
http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html
我建议传递team_name
而不是team_id
,或者您可以从ID中找出team_name
。我甚至会传递你需要的所有东西,比如“城镇”,“性别”,“排名”,“运动”等
RewriteEngine on
RewriteRule ^teams-([a-zA-Z0-9_-]+)$ teams.php?team_name=$1
或者
RewriteEngine on
RewriteRule ^teams-([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+)-([a-zA-Z0-9_-]+)$ teams.php?team_town=$1&team_gender=$2&team_rank=$3
答案 1 :(得分:-1)
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ [URLHERE] [NC]