简体   繁体   English

.htaccess删除PHP扩展名并重定向

[英].htaccess remove php extension AND redirect

I know how to redirect pages, but I was wondering how I could remove the .php extension as well as redirect? 我知道如何重定向页面,但是我想知道如何删除.php扩展名以及重定向?

Here's what I have so far: 这是我到目前为止的内容:

<Files .htaccess>
order allow,deny
</Files>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(\w+)$ ./load.php?code=$1

Thank you in advance, 先感谢您,

I saw a thread here discuss the same issue. 我在这里看到一个讨论相同问题的话题。 http://www.webmasterworld.com/apache/4148146.htm http://www.webmasterworld.com/apache/4148146.htm

You can use this answer in that topic of jDMorgan It will check if the request is not assets files and if it exist extension php in the url, they will redirect and remove .php 您可以在jDMorgan的主题中使用此答案。它将检查请求是否不是资产文件,并且该请求在URL中是否存在扩展名php,它们将重定向并删除.php。

RewriteRule %{REQUEST_URI} !\.(gif|jpe?g|png|css|js|zip)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ [b]/$1[/b].php [b][L][/b]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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