dcsimg
www.webdeveloper.com
Results 1 to 9 of 9

Thread: Redirects with apache

  1. #1
    Join Date
    Feb 2004
    Location
    Brasil porto Aelgre
    Posts
    544

    Redirects with apache

    Hi

    i need to redirect many adress like: http://somehost/someaplication/somef...eter=somevalue

    to something like: http://somehost/someaplication/somenameofuser

    I will have hundreds of adress to redirect each one with diferent values for somenameofuser and the corresponding somevalue

    Wich is the best way ? create a .htaccess? how is it done

    Thank´s in advance

  2. #2
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Read up on mod_rewrite.

  3. #3
    Join Date
    Feb 2004
    Location
    Brasil porto Aelgre
    Posts
    544
    This is almost the rule i need

    RewriteEngine on
    RewriteRule ^userid/([^/\.]+)/?$ index.php?userid=$1 [L]

    But instead i need that someuser be translated as userid=1 and otheruser be translated as userid=2

    How can it be done ?

    Thank´s in advance

  4. #4
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Code:
    RewriteEngine on
    RewriteRule ^userid/([^/\.]+)/?$ index.php?userid=$1 [L]
    These rules will rewrite a URL from something like ...
    http://yoursite.com/userid/svidgen/
    to
    http://yoursite.com/index.php?userid=svidgen

    Isn't that what you want?

  5. #5
    Join Date
    Feb 2004
    Location
    Brasil porto Aelgre
    Posts
    544

  6. #6
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    I'm pretty sure apache can't do database lookups for you. You need to have the script handle that.

  7. #7
    Join Date
    Feb 2004
    Location
    Brasil porto Aelgre
    Posts
    544
    Thank you Svidgen

  8. #8
    Join Date
    Feb 2004
    Location
    Brasil porto Aelgre
    Posts
    544
    I will have the same result creating a folder inside the blog directory with an index file inside having a redirect using PHP like:
    <?header('location: http://yoursite.com/blog/index.php?userid=123222');?>

    My goal was to avoid to do that because of the work to maintain hundreds of directories.

    Cheers

  9. #9
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    No ... you just need one script to lookup a username in the database and process the page accordingly.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles