簡體   English   中英

htaccess remove.php 特定文件的擴展名

[英]htaccess remove .php extension on specific file

我需要能夠重寫特定頁面,以便刪除 .php 擴展名:

http://www.mywordpresswebsite.com/my-landing-page.php

到:

http://www.mywordpresswebsite.com/my-landing-page
http://www.mywordpresswebsite.com/my-landing-page/

同樣,我需要特別刪除一個文件的擴展名,而不是每個文件。

編輯:

RewriteRule ^web/?$ web.php  [NC]

對於想要刪除特定文件擴展名的 WordPress 用戶,請確保在索引重寫規則之前包含它,以便它可以匹配它。 這可以從 Wordpress 環境中的特定文件 (validation.php) 中刪除 .php 擴展名(注意我是如何在<IfModule mod_rewrite.c>之后添加規則的),使 yourwebsite.com/validation 有效。

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteRule ^validation$ validation.php [L]
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

暫無
暫無

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

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