简体   繁体   中英

htaccess remove .php extension on specific file

I need to be able to rewrite a specific page so that the.php extension is removed:

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

to:

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

Again, I need to remove the extension for one file in particular , not every file.

编辑:

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

For WordPress users that want to remove the extension for a specific file, make sure to include it before the index rewrite rule, so it can match it. This works to remove the.php extension from a specific file (validation.php) in a Wordpress Environment (note how I added the rule after <IfModule mod_rewrite.c> ), making yourwebsite.com/validation works.

# 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM