在 URL 中添加组名,并在没有索引的情况下访问该 URL


Adding the Group Name in URL and Accessing that URL without index Page

用户可以在我的网站中创建自己的组。

他们可以使用所需的组名称进行创建。

也就是说,"http://mysite.com/groups/"________

-

-例如:http://mysite.com/groups/test_group

("http://mysite.com/groups/"是默认值,然后用户可以添加他们想要的名称,并且我使用唯一名称进行维护)。

我有一个索引.php在"组"目录中。

不想用" http://mysite.com/groups/index.php?name=test_group"访问...

我想用"http://mysite.com/groups/test_group"访问

如何在不提及核心 PHP 中带有参数段的index.php的情况下实现它?

提前感谢...

启用mod_rewrite.htaccess httpd.conf,然后将以下代码放入DOCUMENT_ROOT/gaggletrips/.htaccess文件中:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /gaggletrips/
RewriteRule ^(groups)/([^/]+)/?$ $1/index.php?name=$2 [L,QSA,NC]

这些规则到位后,您可以直接键入http://mysite.com/groups/test_group,它将在后台加载http://mysite.com/groups/index.php?name=test_group,而无需更改浏览器中的 URL。