PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 27th, 2007, 04:21 AM
cancer10 cancer10 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Location: India
Posts: 41 cancer10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 24 m 53 sec
Reputation Power: 12
Send a message via ICQ to cancer10 Send a message via AIM to cancer10 Send a message via MSN to cancer10 Send a message via Yahoo to cancer10
Question Server settings - .htaccess Question

Well, im trying to get user profiles to be in a virtual directory e.g:
http://mydomain.com/profiles.php?user=test and i want to get it to display something like http://test.mydomain.com, could someone please post me the EXACT full .htaccess file for that example please?
Thanks

Reply With Quote
  #2  
Old September 27th, 2007, 11:14 AM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 14
rewrite

Using Apache's httpd.conf and .htaccess files to control HTTP requests requires regular expression knowledge. And the order of the directives can have an effect too.
Getting something to "display something like" requires thinking about both what exactly is wanted, and what is not wanted.
IMHO if you do not understand how regex works and/or directive syntax, then you are better off leaving this alone.
As only you truly understand what your objectives are, I would be wary of using anyone elses code unless you fully understand what's going on. Often times what "works" has unexpected "side effects".

What do you have in your htaccess file(s) now?

EDIT:
Check out DK Lynn's "mod_rewrite: 13 Real-world Examples"

Last edited by Mittineague : September 27th, 2007 at 11:29 AM.

Reply With Quote
  #3  
Old September 27th, 2007, 11:18 AM
cancer10 cancer10 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Location: India
Posts: 41 cancer10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 24 m 53 sec
Reputation Power: 12
Send a message via ICQ to cancer10 Send a message via AIM to cancer10 Send a message via MSN to cancer10 Send a message via Yahoo to cancer10
This is what i have in my .htaccess file


# Enable mod_rewrite, start rewrite engine
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^user/([^/]+)/?$ /profiles.php?user=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /profiles\.php\?user=([^&]+)\ HTTP/
RewriteRule ^profiles\.php$ http://myweblogin.info/user/%1? [R=301,L]

Reply With Quote
  #4  
Old September 27th, 2007, 12:03 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 14
rewrite

Well, at least the file is relatively "lean". That should simplify matters somewhat.
When I write directives I "translate" between "human" and "regex". For example
RewriteRule ^user/([^/]+)/?$ /profiles.php?user=$1 [L]
says
requests beginning with the string "user/", followed by 1 or more characters that are not a slash, ending with an optional slash are rewritten to /profiles.php?user= whatever the "1 or more characters that are not a slash" are, "last rule".
Personally, I would be more restrictive for security reasons.
eg. user/username&global_var=mal_val
but if you can phrase what you want, it will help in writing a good regex.
If you're lucky, you may find a good example in DK Lynn's "mod_rewrite: 13 Real-world Examples" article.

Reply With Quote
  #5  
Old September 27th, 2007, 12:15 PM
cancer10 cancer10 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Location: India
Posts: 41 cancer10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 24 m 53 sec
Reputation Power: 12
Send a message via ICQ to cancer10 Send a message via AIM to cancer10 Send a message via MSN to cancer10 Send a message via Yahoo to cancer10
well,

What i want it when i type http://mydomain.com/whatever in the browser, it should use the following url

http://mydomain.com/profile.php?user=whatever

Last edited by cancer10 : September 27th, 2007 at 12:20 PM.

Reply With Quote
  #6  
Old September 27th, 2007, 05:33 PM
Mittineague's Avatar
Mittineague Mittineague is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jul 2005
Location: West Springfield, Massachusetts
Posts: 552 Mittineague User rank is Private First Class (20 - 50 Reputation Level)Mittineague User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 1 m 33 sec
Reputation Power: 14
rewrite

It seems you're in luck. There is an example of that in the DK Lynn article. (can't post link) search for "mod_rewrite: 13 Real-world Examples".

Reply With Quote
  #7  
Old September 28th, 2007, 01:18 AM
cancer10 cancer10 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Location: India
Posts: 41 cancer10 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 24 m 53 sec
Reputation Power: 12
Send a message via ICQ to cancer10 Send a message via AIM to cancer10 Send a message via MSN to cancer10 Send a message via Yahoo to cancer10
Ok but can you please PM me the direct link?


Thanx

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Server settings - .htaccess Question


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap