Forum Moderators: phranque

Message Too Old, No Replies

pass username without query string

         

slumberjer

5:23 am on Nov 11, 2008 (gmt 0)

10+ Year Member



Hi..

I'm trying to develop my own affiliate replicate website.
I was wondering how to create a replicate website without using query string.
Here's what i meant:-

www.mydomain.com/username

instead of

www.mydomain.com/?id=username

I've tried myself using .htaccess, nothing work..

Thanks

g1smd

12:10 pm on Nov 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What code did you try?

This type of rewrite is about as simple as it gets, when there is only one parameter involved.

Change the links on your pages to the new URL format, as it is links that define URLs.

Set up redirects so that requests for non-canonical URL formats will redirect to the canonical form of your URL, ie non-www to www etc.

Set up rewrite that takes the URL request and fetches the content from the dynamic internal filepath.

Optionally, set up a redirect such that if someone asks for the URL with parameters they are redirected to the new format URL. This stops both formats being indexed as Duplicate Content.

There are examples in the threads listed in the sticky note at the top of the forum, and in many other threads as almost the same question is asked at last a couple of times every week.

See also: [webmasterworld.com...] for an example with two parameters.

slumberjer

2:08 am on Nov 12, 2008 (gmt 0)

10+ Year Member



Hi g1smd..

Thanks for quick reply.

Here what i did

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ default?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ default.php?username=$1

Actually what i'm trying to is here.When somebody type tge (a) url
they will be redirect to www.mydomain.com/default.php
In the default page, the username will appeared as the owner of the web.

a) www.mydomain.com/username

instead of

b) www.mydomain.com/?id=username

Thanking you in advance

g1smd

2:21 am on Nov 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your links will need to use the URL format shown in (a).

Your rewrite code needs [L] on the end of the rule.

You have two rewrites, which potentially means that both URLs with and without a trailing slash will be indexed by search engines. Additionally each of those will be indexed both with and without the www in the URL.

You should redirect URL requests with slash to URLs without slash, before the rewrite kicks in. The redirect should also force www at the same time for those requests.

Additionally, if someone directly requests URL format (b) they should be redirected to URL format (a) and the www forced at the same time in the same rule.

The example I linked above has all of these elements included.

slumberjer

11:06 am on Nov 12, 2008 (gmt 0)

10+ Year Member



Hi g1smd

I just want to check with you whether my syntax is correct or not.
Here's what i did

######.htaccess file#######

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ check.php?username=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/$ check.php?username=$1 [L]

when i type www.mydomain.com/username
it will redirect to www.mydomain.com/default.php

At the check.php, i did some coding to read the variable from url as below:

$ref = $HTTP_COOKIE_VARS["ref"];

Is that the correct way to pass the variable.One more thing how do i
configure the .htaccess file to read the space bar. What i mean is when the user
type something like "robin hood"

Thanking you in advance

g1smd

11:56 am on Nov 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What you have there is not a redirect. It is a rewrite.

You have two rewrites which are wide open to Duplicate Content indexing... both www and non-www and both with and without trailing slash all serve the same content.

Check my post above, and correct those things, before we move on to additional questions.

See also: [webmasterworld.com...] for an example with two parameters, but which shows all the steps you need.