[英]htaccess Rewrite Rule For Multiple Site Sections
I'm trying to roll my own user registration script in PHP. 我正在尝试在PHP中滚动我自己的用户注册脚本。 I have users and groups. 我有用户和组。
I want people to be able to access user profiles at domain.com/users/username 我希望人们能够访问domain.com/users/username上的用户配置文件
and group profiles at domain.com/groups/groupname 和组配置文件位于domain.com/groups/groupname
In my htaccess I have the following: 在我的htaccess中,我有以下内容:
Options -Indexes
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /users/index.php?username=$1
This works for users but I have no idea how to modify this to work for groups too. 这适用于用户,但我不知道如何修改它以适用于组。 I'm sure this is a very simple adjustment but I've had little luck Googling solutions. 我敢肯定,这是一个非常简单的调整,但是我在Google谷歌搜索解决方案中运气不好。
Thanks. 谢谢。
Have your 2 rules setup like this: 将您的2条规则设置如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^users/([^/]+)/?$ /users/index.php?username=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^groups/([^/]+)/?$ /groups/index.php?groupname=$1 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.