【问题标题】:Removing .php extension except sub directory called enquire删除 .php 扩展名,除了名为 inquire 的子目录
【发布时间】:2022-11-25 15:18:31
【问题描述】:

请协助我阻止删除子目录中的 .php 扩展名,例如:www.example.com/enquire/contactmail 而不是:www.example.com/enquire/contactmail.php

重写引擎开启

重写基础 /

RewriteCond %{REQUEST_FILENAME} !-d

#####排除/cp文件夹####

RewriteCond %{REQUEST_URI} !^/查询

RewriteCond %{REQUEST_FILENAME}\.php -f

重写规则 ^(.*)$ $1.php

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /((?!cp)[^.]+)\.php

重写规则 ^/?(.*)\.php$ /$1 [NC,L,QSA,R=301]

RewriteRule ^enquire/(.*)$ contactmail.php?s=$1 [NC,L,QSA]

RewriteRule ^enquire/([0-9]+)$contactmail.php?a=$1 [NC,L,QSA]

【问题讨论】:

    标签: .htaccess redirect contacts subdirectory php-extension


    【解决方案1】:

    只需使用 blow .htaccess 删除 .php 扩展名

    IndexIgnore * # prevent directory listing
    Order deny,allow
    Allow from *
    
    # ------------------------------------------
    # Rewrite so that php extentions are not shown
    RewriteEngine on
    
    #.php URL Rewrite
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-27
      • 2019-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多