OK, I've been searching numerous discussion boards and searching the archives and the web for just the right answer to this question, even posted related questions on a couple, and got some responses, but they never really 'Solved' my dilema.

I've concluded that I can't use a url like

http://username.domainname.com unless I actually have a sub-domain set up for it, and I can't create a catchall sub-domain using WHM by using '*'.

SO, I've decided I can live with a url like this:

http://www.domainname.com/username

The objective is to capture what is entered as the username, and then redirect to an active php page that will take that username, assign it to a session variable, and do a DB query for all the information about that member to be displayed.

Here is my question:
If I have the following in the .htaccess file:

RewriteEngine On
RewriteRule ^member/[a-zA-Z0-9]+$ index.php?m=$1 [NC,L] # captures member username no case last rule

and the URL they used to get there was http://www.domainname.com/member/username

it will be looking for the 'index.php' to be located in the member directory, right?

But, if I want it redirected to the www.domainname.com/index.php page, how would I write that in the RewriteRule? Can you go back a directory with ../ or is there another way to accomplish that without having to use the domain name (keeping it transportable between domains)


I would like it to go to the domain index page where I can capture the value of m which will be checked against the database for a matching member username, and display their website if a match exists, but if no match exists, then I can just display a message that this is a member only site, or whatever.

This doesn't seem like it should be that difficult to do, but I've been beating my head against this computer monitor for days.

Any assistance with this request would be GREATLY appreciated.

Hopefully I will get a final resolution here today, so I can move on with this project.

Thanks in advance.

Doug

OK, OK, I was overcomplicating it.

I decided I couldn't kill my computer if I tested it out with a few variations on the rewrite and folder options.

Here is what I discovered.

RewriteEngine On
RewriteRule ^[a-zA-Z0-9]+$ index.php?m=$1 [NC,L]

Works fine for redirecting without having to use the /member/ folder
and I can still access scripts in sub-folders. It appears that apache sees sub-folders before it checks the RewriteRules. (that is a good thing)

Anyway, the URL is http://www.domainname.com/username

And it gets to the domainname.com/index.php where I wanted it.

Only problem is that the variable m doesn't have any value

What am I missing here?

Again, thanks in advance for any help you can provide.

Doug

Try this:

RewriteEngine On   
rewriteRule ^([a-zA-Z0-9_-]+)$ index.php?m=$1

Try this:

RewriteEngine On   
rewriteRule ^([a-zA-Z0-9_-]+)$ index.php?m=$1

You are absolutely correct sops21.

Amazing how correct syntax makes things work the way they are supposed to.

Thanks
I guess I can consider this one resolved...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.