Access a single page in multiple "pathname"

0

I'm creating some pages for a site that would show the profile of a particular person using a path in the url (pathname)

Example:

  • demo.com/page/IagoBruno
  • demo.com/page/RodriggoDell

All these domains would show the same page (in php) and in that page would be placed a code to look for information of the profile quoted in that path of the url, in the case: IagoBruno or RodriggoDell.     

asked by anonymous 18.12.2014 / 13:38

1 answer

5

Use mod_rewrite . How can you redirect requests from:

demo.com/page/IagoBruno to demo.com/page.php?username=IagoBruno

or:

demo.com/page/RodriggoDell to demo.com/page.php?username=RodriggoDell

In this particular case, the mod_rewrite configuration looks like this:

RewriteEngine On
RewriteBase /
RewriteRule ^page/([A-Za-z0-9_-]+) /page.php?username=$1 [L]

Obviously the module should be enabled in Apache.

    
18.12.2014 / 13:42