replacing .php ext with .html through .htaccess

前端 未结 4 1320
无人及你
无人及你 2020-12-03 03:57

Greetings!

I\'m trying to replace .php extensions with .html

So far I got:

RewriteRule ^(.*)\\.html $1.php

... it works n

相关标签:
4条回答
  • 2020-12-03 04:25
    RewriteRule ^(.*)\.php $1.html [R=301,L]
    RewriteRule ^(.*)\.html $1.php
    

    edit after pulling white rabbit out of the hat

    RewriteEngine on  
    RewriteBase /
    
    RewriteCond %{THE_REQUEST} (.*)\.php  
    RewriteRule ^(.*)\.php $1.html [R=301,L]  
    
    RewriteCond %{THE_REQUEST} (.*)\.html  
    RewriteRule ^(.*)\.html $1.php [L]  
    
    0 讨论(0)
  • 2020-12-03 04:29

    Give this a try:

    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)\.html$ $1.php [L] 
    
    0 讨论(0)
  • 2020-12-03 04:48

    I think that this is much simple

    AddType application/x-httpd-php .html
    

    it just process every .html file as normal .php

    if you want it only for current dir

    <Files *.html>
    ForceType application/x-httpd-php
    </Files>
    
    0 讨论(0)
  • 2020-12-03 04:49
    RewriteEngine on  
    RewriteBase /
    
    RewriteCond %{THE_REQUEST} (.*)\.php  
    RewriteRule ^(.*)\.php $1.html [R=301,L]  
    
    RewriteCond %{THE_REQUEST} (.*)\.html  
    RewriteRule ^(.*)\.html $1.php [L]
    
    0 讨论(0)
提交回复
热议问题