[英]Hide .php extension with url rewriting using .htaccess
我有以下網址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
請幫我。
提前致謝
看一下這個:
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
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ [URLHERE] [NC]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.