簡體   English   中英

Mod_Rewrite不重寫URL

[英]Mod_Rewrite not rewriting URLs

我有以下網址結構:

  • /page.php?file=about
  • /page.php?file=contact
  • 等等

.htaccess文件具有以下代碼:

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /page.php?file=$1 [L]

完全不要嘗試重寫URL。 我正在尋找/about.html、/contact.html之類的東西

是.htaccess代碼還是服務器上的某種設置?

您可以使用:

RewriteEngine On

RewriteCond %{THE_REQUEST} /page\.php\?file=([^\s&]+) [NC]
RewriteRule ^ /%1.html? [R=302,L,NE]

RewriteRule ^([^/]+)\.html$ page.php?file=$1 [L,QSA,NC]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM