开发者

htaccess for subfolders

I'm new htaccess. So i need to rewrite .php to .html in url.

my files located in

http://www.domain.us/sub1/sub2/sub2/index.php

I need to rewrite as http://www.domain.us/sub1/sub2/sub2/index.html.

I tried something

RewriteEngine On
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} site 
RewriteRule ^(.*)\.php$ http://www.domain.us/sub1/sub2/s开发者_如何学JAVAub3/$1.html [R,L]

But It shows 404 error.

Thanks.


Put this code in your DOCUMENT_ROOT's .htaccess file:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond %{THE_REQUEST} ^GET\s/*sub1/sub2/sub2/.*\.php [NC]
RewriteRule ^(.*)\.php$ /$1.html [NC,NE,R=301,L]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜