Apache mod_重写玩家和网站页面的根URL

Apache mod_重写玩家和网站页面的根URL,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我的玩家名称来自根目录something.com/username,我还有一个ID用于加载配置文件表单ID,而不是something.com/ID/1234,但我还希望能够从index.php?page=about from something.com/about加载我的页面,因为只有大约6-10个页面,所以我可以在htaccess中手动创建这些页面。 我还需要我的搜索页面使用参数something.com/search/searchterms 这是我当前的htaccess文件 # BEGIN

我的玩家名称来自根目录something.com/username,我还有一个ID用于加载配置文件表单ID,而不是something.com/ID/1234,但我还希望能够从index.php?page=about from something.com/about加载我的页面,因为只有大约6-10个页面,所以我可以在htaccess中手动创建这些页面。 我还需要我的搜索页面使用参数something.com/search/searchterms

这是我当前的htaccess文件

# BEGIN Pretty Url's
Options -Indexes

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#Rewrite all urls to use slash at the end.
#RewriteRule ^(.*[^/])$ ./$1/ [L,R=301]
RewriteRule ^([_A-Z0-9a-z-+\.]+)/?$ ./pages/player.php?p=$1 [L]
RewriteRule ^id/([_0-9-+\.]+)/?$ ./pages/player.php?id=$1 [L]
# END Pretty Url's

# BEGIN Security Features
# Deny config.php
<files config.php>
  order allow,deny
  deny from all
</files>

# Deny all .hta* files
<files ~ "^.*\.([Hh][Tt][Aa])">
  order allow,deny
  deny from all
  satisfy all
</files>

# Deny access to version file
<files inc/version.php>
  order allow,deny
  deny from all
  satisfy all
</files>

# Deny access to security file
<files inc/security.php>
  order allow,deny
  deny from all
  satisfy all
</files>
# END Security Features
#开始漂亮的Url
选项-索引
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
#重写所有URL以在末尾使用斜杠。
#重写规则^(.*[^/])$./$1/[L,R=301]
重写规则^([\u A-Z0-9a-z-+\.]+)/?$/页面/player.php?p=$1[L]
重写规则^id/([\u 0-9-+\.]+)/?$./pages/player.php?id=$1[L]
#结束漂亮的Url
#启动安全功能
#拒绝config.php
命令允许,拒绝
全盘否定
#拒绝所有.hta*文件
命令允许,拒绝
全盘否定
满足所有
#拒绝访问版本文件
命令允许,拒绝
全盘否定
满足所有
#拒绝访问安全文件
命令允许,拒绝
全盘否定
满足所有
#终端安全特性

只需将它们添加到您已有的规则之上:

RewriteEngine On

RewriteRule ^(about|page1|page2|etc)$ /index.php?page=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([_A-Z0-9a-z-+\.]+)/?$ ./pages/player.php?p=$1 [L]
RewriteRule ^id/([_0-9-+\.]+)/?$ ./pages/player.php?id=$1 [L]

假设您拥有的页面列表是“关于”、“第1页”、“第2页”和“等等”。请注意,这样做意味着您的玩家名称与页面名称相同。

您的问题是什么?太简单了!非常感谢,作为对其他任何可能发现此信息的人的补充,我补充说/?在$之前,这样人们就可以使用/about和/about/加上尾随斜杠。但是关于我的搜索页面还有一个问题,因为我需要将搜索参数传递到/search/somethingsearched