【问题标题】:modrewrite to remove the file extension but still load the pagemodrewrite 删除文件扩展名但仍加载页面
【发布时间】:2013-06-28 10:56:40
【问题描述】:

我有一个包含 .php 页面的子域。我只是想删除 .php 我写了一些从堆栈上的其他帖子收集的代码,到目前为止我有这个

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

这重写 subdomain.example.com/weddings.php

subdomain.example.com/weddings

但是,它也会创建 404 页面未找到错误。我做错了吗?

【问题讨论】:

    标签: html mod-rewrite web


    【解决方案1】:

    解决了。任何在这里遇到同样事情的人都是我的解决方案

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    

    找到了

    http://css-tricks.com/snippets/htaccess/remove-file-extention-from-urls/

    一个很棒的网站。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-12
      • 1970-01-01
      • 1970-01-01
      • 2015-01-03
      相关资源
      最近更新 更多