我剛剛得到的重寫引擎加載和活躍,但無法弄清楚 如何設計一個良好的.htaccess文件。 我想要變換這樣的鏈接:url-rewrite&如何設置它與htaccess
http://localhost/index.php?u=username --> http://localhost/username/
http://localhost/index.php?id=1&v=2 --> http://locahost/1x2
感謝您的幫助!
我剛剛得到的重寫引擎加載和活躍,但無法弄清楚 如何設計一個良好的.htaccess文件。 我想要變換這樣的鏈接:url-rewrite&如何設置它與htaccess
http://localhost/index.php?u=username --> http://localhost/username/
http://localhost/index.php?id=1&v=2 --> http://locahost/1x2
感謝您的幫助!
URL重寫改變:
?HT * P://本地主機/用戶名/ - 與/結束可選
到> HT * P://localhost/index.php U =?用戶名HT * p://本地主機/ 1x2的 - 不區分大小寫(匹配4X4)
至> HT * p://localhost/index.php ID = 1 & v = 2
的.htaccess內容:
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^localhost$ [NC]
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteCond %{REQUEST_URI} ^/([^/\d]+)/?$ [NC]
RewriteRule (.*) index.php?u=%1 [L]
RewriteCond %{HTTP_HOST} ^localhost$ [NC]
RewriteCond %{REQUEST_URI} ^/(\d+)x(\d+)/?$ [NC]
RewriteRule (.*) index.php?id=%1&v=%2 [L]
你的意思是將用戶輸入(左)是那些獲得縮短(如右圖所示)長的網址? – 2013-04-27 16:29:12
我的意思是用戶在右側輸入較短的url地址 – dash 2013-04-27 16:34:43
並且地址欄中的URL應該保留「localhost/username」還是改爲「index.php?u = username」? – 2013-04-27 16:38:22