开发者

.htaccess remove php extension AND redirect

开发者 https://www.devze.com 2023-02-08 03:27 出处:网络
I know how to redirect pages,开发者_开发知识库 but I was wondering how I could remove the .php extension as well as redirect?

I know how to redirect pages,开发者_开发知识库 but I was wondering how I could remove the .php extension as well as redirect?

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

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

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]
0

精彩评论

暂无评论...
验证码 换一张
取 消