.htaccess htaccess删除特定文件.php扩展名

chy5wohz  于 2023-01-31  发布在  PHP
关注(0)|答案(2)|浏览(148)

我需要能够重写一个特定的页面,以便删除. php扩展名:

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

致:

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

同样,我需要删除的扩展名,特别是文件,而不是每个文件。

fhg3lkii

fhg3lkii1#

编辑:

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

mkh04yzy2#

对于想要删除特定文件扩展名的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

相关问题