| :: |
| Author |
Message |
mrblack
Joined: 26 Apr 2007 Posts: 8
|
Posted: Mon Apr 30, 2007 5:15 pm Post subject: www.domain.com/4 Short URL question |
|
|
I want to have redirection look like this
http://www.domain.com/4 instead of http://domain.com/member4.html
Like myspace does with member id's
Later of course I want to create a new field that is filled out it will replace the userid with the field data. But I am sure that is a difficult task so that is on hold for awhile. lol |
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
Posted: Tue May 01, 2007 9:31 am Post subject: Re: www.domain.com/4 Short URL question |
|
|
Actually, thanks to the zero dupe, it's really easy.
You'd only need to add a rewriterule to handle these.
Just add :
| Code: | # shorter PROFILES
RewriteRule ^([0-9]+)$ /profile.php?mode=viewprofile&u=$1 [QSA,L,NC] |
After :
| Code: | #PROFILES
RewriteRule ^membre([0-9]+)\.html$ /profile.php?mode=viewprofile&u=$1 [QSA,L,NC] |
in your .htaccess (could need to add paths like in your other rewriterules).
The zero dupe will do the rest
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
mrblack
Joined: 26 Apr 2007 Posts: 8
|
Posted: Tue May 01, 2007 3:21 pm Post subject: Re: www.domain.com/4 Short URL question |
|
|
thanks that worked you are a life saver. How hard would it be to create redirecting from http://www.domain.com/customurl and custom url being a costom field I added via registration? |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
Posted: Tue May 01, 2007 3:29 pm Post subject: Re: www.domain.com/4 Short URL question |
|
|
Well, it all depends on what would be the variables content and how you'd catch it by the script.
If the variable only contains a text strig without spaces, you could go for something like :
| Code: | RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-z0-9]+)$ /script.php?var=$1 [QSA,L,NC] |
We need the rewritecond here to first make sure a physical file with the same name as the text string sent does not really exist, in such case, we give it the priority to let it load.
If you where using a folder with only script.php in it, you could have the reg-ex working faster with only :
| Code: |
RewriteRule ^folder/([a-z0-9]+)$ /folder/script.php?var=$1 [QSA,L,NC] |
But this is only a possible example, what would you put into this added field, and what would you like to do with it ?
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
mrblack
Joined: 26 Apr 2007 Posts: 8
|
Posted: Tue May 01, 2007 4:28 pm Post subject: Re: www.domain.com/4 Short URL question |
|
|
custom field would be restricted of special characters/spaces and limited to 20 characters. I know how to add a custom field to profile/registration cause I read the tutorial lol. Example.
Custom URL: http://www.scenespot.com/ [text input]
Once chosen your custom url cannot be changed.
http://www.phpbb.com/community/viewtopic.php?f=35&t=86960&st=0&sk=t&sd=a
is the url for the tutorial I used to add a new field. So that part I understand and have used this for other things to display data in the profile. but once I have created it lets call it 'customurl' then how do I get that to redirect using that data? |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
|
| Back to top |
|
 |
mrblack
Joined: 26 Apr 2007 Posts: 8
|
Posted: Wed May 02, 2007 4:15 pm Post subject: Re: www.domain.com/4 Short URL question |
|
|
| the input will be stored in database and hopefull take you to the profile jusy as http://www.scenespot.com/4 would |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
Posted: Wed May 02, 2007 4:52 pm Post subject: Re: www.domain.com/4 Short URL question |
|
|
Then, assuming you'll be using a new GET var for this one, and deal with it in the php script to link it to the user id, this should do it, preferably at the end of your .htaccess to avoid possible confusion with other rules :
| Code: | RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-z0-9]+)$ /profile.php?mode=viewprofile&stringvar=$1 [QSA,L,NC] |
You should, with this, use $_GET['stringvar'] in profile.php to catch this var.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
|
|