【问题标题】:Change .php to .html through htaccess通过 htaccess 将 .php 更改为 .html
【发布时间】:2017-08-04 07:15:52
【问题描述】:

我有一个提供步骤注册1、步骤注册2的程序。我的结构是这样的:

localhost/bandung/registration.php

那么当提交按钮时,页面会发送参数

localhost/bandung/registration.php?user=xxxxxx

我可以将php的扩展名更改为html但仍然有类似的参数:

localhost/bandung/registration.html?user=xxxxxx

【问题讨论】:

标签: php html .htaccess


【解决方案1】:

在您的 bandung 文件夹中创建一个新的 htaccess 文件。然后在其中添加以下行:

# Set Rewrite Engine on
RewriteEngine on

# Create rewrite rule for your registration.php
RewriteRule ^registration.html?user=(.*)$ registration.php?user=$1 [R=301,L]

【讨论】:

    【解决方案2】:
    RewriteRule ^(.*)\.php $1.html [R=301,L]
    RewriteRule ^(.*)\.html $1.php
    

    把白兔从帽子里拉出来后编辑

    RewriteEngine on  
    RewriteBase /
    
    RewriteCond %{THE_REQUEST} (.*)\.php  
    RewriteRule ^(.*)\.php $1.html [R=301,L]  
    
    RewriteCond %{THE_REQUEST} (.*)\.html  
    RewriteRule ^(.*)\.html $1.php [L]
    

    【讨论】:

      猜你喜欢
      • 2011-05-31
      • 1970-01-01
      • 2014-07-24
      • 2011-06-30
      • 2011-09-26
      • 2012-12-10
      • 2013-09-12
      • 2014-05-09
      • 1970-01-01
      相关资源
      最近更新 更多