tags:

views:

40

answers:

2

Hello,

I have the URL http://localhost/mydirector/, I want to echo mydirectory and not have a 404 error. mydirectory does not exist as a directory, but is taken as username. I am using Windows/apache/MySQL,PHP. All this happening on localhost or 127.0.0.1

Thanks Jean

A: 

You need to use mod_rewrite so that it internally rewrites the URL to another URL.

For example:

http://localhost/mydirector/

To:

http://localhost/index.php?z=mydirector

Then you can have index.php to read and echo the 'z' parameter value.

There is a lot of information on the net about using mod_rewrite to do this. For example: http://articles.sitepoint.com/article/guide-url-rewriting

zaf
Yup I can do that, and know that
Jean
@Jean what is your question then?
Pekka
@pekka localhost is the domain name mydirectory is the username eg digg.com/username
Jean
@Jean yes but *what is your question?*
Pekka
How do I get to do that on my local machine or 127.0.0.1
Jean
@Jean get to do what? I still don't understand what your actual question is.
Pekka
@Jean If my answer is what you were looking for but you don't know what the mod_rewrite code would be then accept this answer and open another question with this specific mod_rewrite problem. You'll get an answer from the mod_rewrite experts very fast.
zaf
@Jean Part of the confusion stems from the fact that you're contradicting yourself. In response to zaf's answer on mod_rewrite you say 'I can do that', then you turn around and say 'How do I get to do that on my local machine?'. Try rephrasing using words you haven't used in a previous statement.
Mike B
+1  A: 

if mod_rewrite isn't what you want, have you investigated mod_userdir?

http://httpd.apache.org/docs/2.0/mod/mod_userdir.html

oedo