View Full Version : URL format
StarXploser
January 3rd, 2006, 02:04 AM
Hi,
How do you create pages like:
www.url.com/user1
www.url.com/user2
instead of
www.url.com/?user=user1
StarXploser
January 3rd, 2006, 04:29 AM
If you don't know how to do it, but know the name of the process, tell me please.
FreakSheep
January 3rd, 2006, 11:09 AM
I know you can do it with php or asp. You put it as the 404 page, then redirects you to the page your want. With Apache, you can do it with mos_rewrite (i think thats it). ill get some more info for you later, but I really have to get on this paper I have to write :(
playboyadonis
January 3rd, 2006, 11:12 AM
what's your server language
StarXploser
January 3rd, 2006, 12:09 PM
php
StarXploser
January 4th, 2006, 02:43 AM
anyone knows what it's called ?
StarXploser
January 4th, 2006, 02:47 AM
I know you can do it with php or asp. You put it as the 404 page, then redirects you to the page your want. With Apache, you can do it with mos_rewrite (i think thats it). ill get some more info for you later, but I really have to get on this paper I have to write :(
Well, I googled mos_rewrite, and i think you meant mod_rewrite. I found a few sites that explain how to do it, so i'll try that. thx for your help.
hl
January 4th, 2006, 05:53 PM
Well, I googled mos_rewrite, and i think you meant mod_rewrite. I found a few sites that explain how to do it, so i'll try that. thx for your help.
indeed, mod_rewrite.. you create a .htaccess file in your public_html directory, inside of it, you could put something like this
RewriteEngine On
RewriteRule ^user([0-9]) /?user=$1
Jeff Wheeler
January 4th, 2006, 06:09 PM
Actually, it should be:
RewriteEngine On
RewriteRule ^user([0-9]) /?user=user$1
According to his original question ;)
;P
hl
January 4th, 2006, 06:33 PM
Actually, it should be:
RewriteEngine On
RewriteRule ^user([0-9]) /?user=user$1
According to his original question ;)
;P
un typo
Jeff Wheeler
January 4th, 2006, 09:06 PM
huh?
StarXploser
January 5th, 2006, 03:32 PM
Thx for the replies.
I've been playing with mod_rewrite and thats what i came up with:
RewriteRule "^([^/\.]*)/?$" "bio.php?user=$1"
and it works like this:
www.url.com/someUser -> www.url.com/bio.php?user=someUser
like on myspace.com
but then if I type www.url.com it translates it to www.url.com/bio.php?user=
and I don't wan that. I want it t go to index.php.
so i added this:
RewriteCond %{REQUEST_URI} "^\$"
RewriteRule ^(.*) index.php
if the query is empty > go to index.php
doesn't work. I'm having problem with the syntax and i can't find a site that makes it clear.
can someone help ?
Thx
hl
January 5th, 2006, 04:26 PM
Thx for the replies.
I've been playing with mod_rewrite and thats what i came up with:
RewriteRule "^([^/\.]*)/?$" "bio.php?user=$1"
and it works like this:
www.url.com/someUser -> www.url.com/bio.php?user=someUser
like on myspace.com
but then if I type www.url.com it translates it to www.url.com/bio.php?user=
and I don't wan that. I want it t go to index.php.
so i added this:
RewriteCond %{REQUEST_URI} "^\$"
RewriteRule ^(.*) index.php
if the query is empty > go to index.php
doesn't work. I'm having problem with the syntax and i can't find a site that makes it clear.
can someone help ?
Thx
that's why a lot of people either use a seperate directory, or a special character like ~ with the username, it prevents index.php from being considered. of course there must be some regex to make it not do anything to a file with an extension such as php.
StarXploser
January 5th, 2006, 04:49 PM
well, the .php stuff work. for example url.com/index.php works.
but url.com/ doesnt.
RewriteRule "^([^/\.]*)/?$" "bio.php?user=$1"
takes care of periods and slashes
so url.com/aaa/aaa
would not be considered
and url.com/aaa.php or url.com/aaa.gfdgfdgd or url.com/aa/aa.php wouldnt be considered.
my problem is that i dont know how to test for a BLANK. i tried but it's not working.
StarXploser
January 5th, 2006, 05:21 PM
got it:
RewriteCond %{REQUEST_URI} !^/$
RewriteRule "^([^/\.]*)/?$" "bio.php?user=$1"
expensive_pen
January 5th, 2006, 05:30 PM
you can do that in java when you map your servlets
Jeff Wheeler
January 5th, 2006, 06:11 PM
got it:
RewriteCond %{REQUEST_URI} !^/$
RewriteRule "^([^/\.]*)/?$" "bio.php?user=$1"
I think instead, you could've changed the * in the regex to a plus ;)
chunk
January 6th, 2006, 02:34 AM
If
RewriteCond %{REQUEST_URI} !^/$
RewriteRule "^([^/\.]+)/?$" "bio.php?user=$1"
Redirects anyone that goes to url.com/qwerty to url.com/bio.php?user=qwerty but ignores / and . what would it be for it to ignore everything but / and . ?
somthing like:
RewriteCond %{REQUEST_URI} !^/$
RewriteRule "^(/\.)/?$" "bio.php?user=$1"
So when someone types: url.com/hello/anyone it would redirect you to, url.com/bio.php?user=hello
?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.