Adding a group name to a URL and accessing that URL without an index page

Users can create their own group on my site.

They can create with the desired group name.

That is, http://mysite.com/groups/ "_______

- Example: http://mysite.com/groups/test_group

(' http://mysite.com/groups/ ' by default, then users can add their name and save with a unique name).

I have one index.php in the 'groups' directory.

I do not want to access using http://mysite.com/groups/index.php?name=test_group"...

I want to access using < http://mysite.com/groups/test_group"

How to do this without mentioning the index.phpparameter segment in Core PHP?

Thanks in advance...

+4
source share
1 answer

Include mod_rewriteand .htaccessthrough httpd.conf, and then put this code in your file DOCUMENT_ROOT/gaggletrips/.htaccess:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /gaggletrips/

RewriteRule ^(groups)/([^/]+)/?$ $1/index.php?name=$2 [L,QSA,NC]

Once these rules are in place, you can directly type http://mysite.com/groups/test_groupand it will load http://mysite.com/groups/index.php?name=test_groupbackstage without changing the URL in the browser.

+2
source

All Articles