再會,
我想將我的用戶 ID URL 重寫為我網站上的物理頁面,請參見下面的 URL 結構:
來自:http://localhost:8888/report.mark1/user.php?id=341
至:http://localhost:8888/report.mark1/341
這是 .htaccess 檔案代碼:
ReWriteEngine On
RewriteRule ^report.mark1([^/.] )?$ /user.php?id=$1 [L]
我錯過了什么?
uj5u.com熱心網友回復:
使用您顯示的示例,請嘗試遵循 htaccess 規則檔案。確保您的 .htaccess 檔案與 report.mark1 檔案夾一起存在,并且您的 user.php 存在于 report.mark1 檔案夾中。
確保在測驗 URL 之前清除瀏覽器快取。
RewriteEngine ON
RewriteBase /report.mark1/
##External redirect change of URL rules here.
RewriteCond %{THE_REQUEST} \s/(report\.mark1)/user\.php\?id=(\d )\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
##Internal rewrite to user.php rules here.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:[^/]*)(\d )/?$ /report.mark1/user.php?id=$1 [QSA,L]
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/477656.html
