Php 用户配置文件的htaccess url重写

Php 用户配置文件的htaccess url重写,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,每个注册成员都有一个用户配置文件。URL看起来像: 如何重写它,使其显示URL: 我试过: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteRule ^([^/]*)\.html$ content/profile/$1 [L,QSA] 但它不起作用,我也不知道 编辑#1 此外,我的地图结构如下所示: content/example1/example

每个注册成员都有一个用户配置文件。URL看起来像:

如何重写它,使其显示URL:

我试过:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^([^/]*)\.html$ content/profile/$1 [L,QSA]
但它不起作用,我也不知道

编辑#1

此外,我的地图结构如下所示:

content/example1/example_file1.php
content/example2/example_file2.php
content/example3/example_file3.php
如何隐藏内容/示例/地图?因此:domain.com/content/example2/example_file2.php

变成domain.com/example\u file2

谢谢

这应该有效:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /content/profile/profile\.php\?username=(.*)\ HTTP
RewriteRule ^ /%2? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /content/profile/profile.php?username=$1 [L]

校正每当我转到根目录中的文件时,它都会显示一个空的用户配置文件。只有当该文件不存在时才会出现这种情况?我忘了提到我还想删除.php扩展名。每当我输入:domain.com/index.php时,索引页面就会出现。当我输入domain.com/index时,它显示一个不存在的配置文件。相反,它应该显示索引。这是因为,由于用户名url是
example.com/somename
,它将以静默方式重写它。因此,如果您试图从URL中删除
.php
扩展名,如何知道哪个是用户名,哪个是文件?这是一个好问题,lmfao。既然我想通过domain.com/userprofile显示用户配置文件,那么最好的做法是什么?是否为非配置文件页面使用子域?那么索引呢。。