SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Put Name in the URL

    Hello
    i need to know how in many sites they r making the URL like that

    for example:
    http://twitter.com/NAME

    any idea?????????????????

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    my mobile portal
    ghiris.ro

  3. #3
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    it is done in a .htaccess file using regular expressions. I am still learning them. So most likely native twitter URL's are like twitter.com/$u=NAME and they use reg exp to map it.
    Ryan B | My Blog | Twitter

  4. #4
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I doubt twitter even uses webserver that supports .htacess file

  5. #5
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its in facebook and many new sites too

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shrapnel_N5 View Post
    I doubt twitter even uses webserver that supports .htacess file
    Really? I beg to differ

  7. #7
    SitePoint Enthusiast
    Join Date
    May 2009
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think putting the username as a location rather than a querystring is actually a lot more secure for the website, and it makes it easier to find people.

  8. #8
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    simply done as (in .htaccess):
    Code:
    Options -Indexes
    Options +FollowSymlinks
    
    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule ^(.*?)/([a-zA-Z0-9]+)$ index.php?username=$2 [QSA,L]

  9. #9
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dakota G View Post
    I think putting the username as a location rather than a querystring is actually a lot more secure for the website...
    Why is it more secure or any different then a query string?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  10. #10
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Security all depends on how you code.
    Rule of thumb:
    1> Filtering input
    2> Escaping output

  11. #11
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PHPycho View Post
    simply done as (in .htaccess):
    Code:
    Options -Indexes
    Options +FollowSymlinks
    
    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    
    RewriteRule ^(.*?)/([a-zA-Z0-9]+)$ index.php?username=$2 [QSA,L]

    Thanks PHPycho
    but first i have to create that .htaccess in my folder ,right?
    but second how i will pass the name in my index to appear???

  12. #12
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but first i have to create that .htaccess in my folder ,right?
    Yes of course in root folder. Be sure that you have apache's mod_rewrite module enabled.

    but second how i will pass the name in my index to appear???
    If you have url: http://mysite.com/ausge then you can get that name in index.php as
    $_GET['username']

  13. #13
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    helloo i tried to search for the Friendly URLS
    and i found a good article
    http://www.webconfs.com/url-rewriting-tool.php

    and i used the generated code and created the .htaccess and edited the rewrite module in my local but it didn't work
    and i noticed they were saying it will not work on Windows

    so i uploaded the .htaccess to the online server which is Linux and it didn't work too

    any idea plz????????

  14. #14
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check if mod_rewrite module is enabled in the server.

  15. #15
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well yeah i searched for it
    URL rewriting of this type would work ONLY if you are hosted on a Linux Server.

    and am using windows so i think i will not be able to try it

  16. #16
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using in on windows. Where I am wrong?

  17. #17
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ausge View Post
    well yeah i searched for it
    URL rewriting of this type would work ONLY if you are hosted on a Linux Server.

    and am using windows so i think i will not be able to try it
    It does work in Apache, IIS etc.
    Apache use mod_rewrite module but no idea about IIS.

    You can also via PHP whether mod_rewrite module is enabled or not via php script as:
    PHP Code:
    <?php
    print_r
    (get_loaded_extensions());
    ?>
    alternatively use phpinfo() & checkout apache2handler >> Loaded Modules

    and search for key: mod_rewrite

    if present: enabled else not enabled

  18. #18
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I apologize for my mistake

    PHP Code:
    <?php
    print_r
    (get_loaded_extensions());
    ?>
    should be
    PHP Code:
    <?php
    print_r
    (apache_get_modules());
    ?>

  19. #19
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, am using WAMP in Windows

    and i edited the mod_rewrite

    and created a .htaccess in the project folder

    and put this code
    HTML Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule index1/section/(.*)/ index1.php?section=$1
    RewriteRule index1/section/(.*) index1.php?section=$1					
    and i changed the links to
    http://localhost/project/index1/section/VipAbout

    and it works fineeeeeeeeeeeeee
    BUT it doesn't show any design i don't know why!!!!


    this is index1.php content

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>exclusiveM</title>
    
    <link  href="css/style.css"s rel="stylesheet" type="text/css" />
    <link href="css/menu.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/thumbnailviewer.css" type="text/css" />
    <script language="javascript" src="js/querystring.js" type="text/javascript"></script>
    <script language="JavaScript" src="js/gen_validatorv31.js" type="text/javascript"></script>
    <script language="javascript" src="js/1.js" type="text/javascript"></script>
    <script src="js/thumbnailviewer.js" type="text/javascript"></script>
    <LINK REL="SHORTCUT ICON" HREF="images/m.ico">
    
    
    <script type="text/javascript" src="js_video/mootools.js"></script>
    <script type="text/javascript" src="js_video/swfobject.js"></script>
    
    <script type="text/javascript" src="js_video/videobox.js"></script>
    <link rel="stylesheet" href="css_video/videobox.css" type="text/css" media="screen" />
    </head>
    <body>
    <div id="header">
    				<div id="logo"><img src="images/logo.jpg" width="120" height="128" /></div>
    		<!-- end of logo-->
    		<div id="menu">
    			<ul>
    			<li><a href="http://localhost/exclusiveM/index1/section/VipAbout">why exclusiveM</a></li>
    
    			<li><a href="http://localhost/project/index1/section/VipIncentive">M exclusives</a></li>
    			<li><a href="http://localhost/project/index1/section/VipRewards">rewards</a></li>
    			<li><a href="http://localhost/project/index1/section/VipBenefits">benefits</a></li>
    			<li><a href="http://localhost/project/index1/section/VipEventTickets">event tickets</a></li>
    			<li><a href="http://localhost/project/index1/section/VipWeeklyEvents">movie times</a></li>
    			<li><a href="http://localhost/project/index1/section/VipContact">contact us</a></li>
    
    		 </ul>		</div>
    		<!-- end of menu-->	
    
    	</div><!-- end of header-->
    </body>

  20. #20
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes i discovered

    i need to change all the links to
    http://localhost/project/THE FOLDER NAME

    is there any other easier way instead of changing all the links?????????


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •