views:

25

answers:

2

Hi guys, I have a simple membership project and teh client wishes that urls be simple rather than having something like:

index.php?p=view-member&id=568157&hash=00218546598797898798162454712

he would like to see it as so:

website.com/member/username

Now I've worked with Zend and understand you need to do some htaccess alterations to get this done and this is like already easy to do in Zend Framework but I don't want to use the Zend framework for this as I already have a fully functional membership project I built which I would like to tweak for this project.

I thought of creating empty member folders with a simple php file that would include my main php file but am not sure of what complications I would run into if I use such a system. I'm open to ideas here guys. What do I do?

+4  A: 

You don't need a framework to do this. Just use Apache URL rewriting with mod_rewrite. For example, in .htaccess in your document root (top-level directory that is served):

RewriteEngine On
RewriteBase /
RewriteRule ^member/(\w+)$ /index.php?p=view-member&id=$1

If you need some sort of hash to identify the user, don't put it in the URL (like your hash parameter is). Use a cookie.

You can of course use other Webservers such as IIS or nginx.

cletus
And member.php then must lookup the user to get your user id you work with
jitter
WOW! You mean thats all I have to do to get this to work! DAYAM I actually learnt to use the whole zend framework for the sake of url rewriting - I never actually understood that the htaccess file did all that on its own pretty much - guess thats what happens when I rely on copy pasting from tutorials and taking it from there - Thanks everybody :)
Ali
A: 

If you are running Apache a RewriteRule with mod_rewrite could do the trick. You also have to change index.php so that it takes username as a parameter and stores the hash in a cookie/session instead of in the URL.

Jonas Elfström