Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从url中删除.php,但有例外(htaccess)_Php_Mysql_.htaccess_Url_Url Redirection - Fatal编程技术网

从url中删除.php,但有例外(htaccess)

从url中删除.php,但有例外(htaccess),php,mysql,.htaccess,url,url-redirection,Php,Mysql,.htaccess,Url,Url Redirection,我有以下.htaccess文件: RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ account.php?username=$1 这基本上是为我的用户配置文件服务的,所以像twitter一样,有人可以键入:url.com/theirusername 但是,我想让某些页面,如/home,不会导致一个概要文件,而是一个不同的.php页面,最后也没有.php 有人能想出一个办法吗 谢谢 在此规则之前,您可以添加另一个规则。php: 只需添加更多规则以

我有以下.htaccess文件:

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ account.php?username=$1 
这基本上是为我的用户配置文件服务的,所以像twitter一样,有人可以键入:url.com/theirusername

但是,我想让某些页面,如/home,不会导致一个概要文件,而是一个不同的.php页面,最后也没有.php

有人能想出一个办法吗


谢谢

在此规则之前,您可以添加另一个规则。php:


只需添加更多规则以匹配所有其他页面,将其放在用户名规则之前

RewriteEngine On
RewriteRule ^home$ home.php
RewriteRule ^contact$ contact.php
RewriteRule ^([a-zA-Z0-9_-]+)$ account.php?username=$1

感谢您抽出时间回答。我最后使用了第一个答案。
RewriteEngine On
RewriteRule ^home$ home.php
RewriteRule ^contact$ contact.php
RewriteRule ^([a-zA-Z0-9_-]+)$ account.php?username=$1