簡體   English   中英

重寫.php以顯示.htm

[英]Rewrite .php to display .htm

我想將.php文件顯示為.htm擴展名。 我認為這是可行的,但不可行:

RewriteEngine On
RewriteBase /
RewriteRule ^contact\.php$ contact.htm [NC,R,L]

任何幫助將不勝感激。 謝謝。

將此添加到您的.htaccess文件中以允許HTML文件中的PHP:

# allow HTML files to process PHP
AddType application/x-httpd-php .html .htm

# now the rewrite can occur
RewriteEngine On
RewriteBase /
RewriteRule ^contact\.htm$ contact.php [NC,R,L]

在那里,您可以重寫URL。

你很親密 重寫規則參數已經顛倒了-第一個參數是您正在偵聽的內容(content.html),第二個參數是您要加載的內容(contact.php)。 我還刪除了R標志,以便服務器在內部執行此操作-使用R標志,服務器將向瀏覽器發送命令,以強制其重定向到新位置。

RewriteEngine On
RewriteBase /
RewriteRule ^contact\.htm$ contact.php [NC,L]

暫無
暫無

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

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