SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    from ~username to /usernam

    users on my server can goto mywebaddress.com/~username

    How can i add something to my root directory, so that when they type in mywebaddress.com/username, it goes to mywebaddress.com/username

    Thanks.

  2. #2
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wouldn't a simple redirect do the trick?

    .htaccess
    Code:
    Redirect /~username http://www.mywebaddress.com/username

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Scheiss,

    duuudie's got it right! mod_alias is more appropriate than mod_rewrite (even though less flexible) but this one's simple.
    Quote Originally Posted by apache.org/docs/mod/mod_alias.html
    The Redirect directive maps an old URL into a new one. The new URL is returned to the client which attempts to fetch it again with the new address. URL-path a (%-decoded) path; any requests for documents beginning with this path will be returned a redirect error to a new (%-encoded) URL beginning with URL.

    Example:

    Redirect /service http://foo2.bar.com/service

    If the client requests http://myserver/service/foo.txt, it will be told to access http://foo2.bar.com/service/foo.txt instead.

    Note: Redirect directives take precedence over Alias and ScriptAlias directives, irrespective of their ordering in the configuration file. Also, URL-path must be a fully qualified URL, not a relative path, even when used with .htaccess files or inside of <Directory> sections.
    Thanks, duuudie, for the prod to go find out about that (mod_alias) Redirect!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  4. #4
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. So how could i redirect an image if an image is not found on my page? I have this but it isn't working:

    Code:
    ErrorDocument 404 /shop/img/usr/
    Thankyou.

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Scheisskopf,
    Quote Originally Posted by Scheisskopf
    Thanks. So how could i redirect an image if an image is not found on my page? I have this but it isn't working:

    Code:
    ErrorDocument 404 /shop/img/usr/
    To give you a good (correct) answer would require that we know both the link in the page that can't find the image AND the actual location of that image.

    The article at datakoncepts.com/seo provides a warning about mod_rewrite's effect on relative links. The use of the HTML BASE tag (giving the actual web location of the page) would resolve the problems generated for relative links.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  6. #6
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wouldn't a simple redirect do the trick?
    No because it doesn't actually exist as a folder

    basically /~username shows a users web page on cpanel

    i would like their webpage to show at /username, even though that folder doesn't exist

    is this a mod rewrite problem?

    Either that or add the username so it becomes a sumdomain:

    i.e. from www.site.com/~username to username.site.com

    Thankyou.

  7. #7
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Scheisskopf,

    Quote Originally Posted by Scheisskopf
    i would like their webpage to show at /username, even though that folder doesn't exist

    is that a problem?
    No, it's not a problem!

    Code:
    RewriteEngine On
    RewriteRule ^([a-z]+)(/.*)?$ path-to-$1/$2 [L]
    That should do the trick (**IF** your usernames are lowercase) and keep the scriptname, too!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  8. #8
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Scheisskopf,

    pippo's given a link which led me to the Dynamically configured mass virtual hosting documentation where DYNAMIC virtual hosts can be created. You may want to take a look at that.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •