Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Location
    Orlando, FL
    Posts
    12,200

    * Yet another URL redirect / mod rewrite question

    Alright, if anyone would give me a quick solution to this, I'd be greatful

    I'd like to have this:

    1. http://sampledomain.com/index.php?user=jim_doe

    ...display as this:

    2. http://sampledomain.com/jim_doe

    In other words when http://sampledomain.com/jim_doe is typed, the actual page pulled would be the first one, but the second URL will be displayed.

    Any ideas?

  2. #2
    Try to put this in .htaccess:

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

    Rewrite rule description can be found here: http://look4docs.com/apache+rewriterule.shtml

    But I suggest not to use http://sampledomain.com/jim_doe urls
    just because of possible URL conflicts with http://sampledomain.com/index.php.
    Use http://sampledomain.com/users/jim_doe instead.
    Here is rewrite sample:

    RewriteEngine on
    RewriteRule ^/users/(.*) /index.php?user=$1 [NC,L]
    Search tutorial collection Look4docs.com (Linux, PHP, MySQL, Java and more)

  3. #3
    Join Date
    Mar 2002
    Location
    Orlando, FL
    Posts
    12,200
    Thanks astellar. Why would there be a URL conflict, as long as there is filtration of characters, e.g. allowing only alphanumeric and converting spaces to underscores?

  4. #4
    Join Date
    Mar 2004
    Location
    USA
    Posts
    4,342
    I am trying to redirect from a subdomain to a page (opposite of above).

    i tried to use:

    RewriteCond %{HTTP_HOST} ([^.]+)\.site.com [NC]
    RewriteRule ^(.*) http://www.site.com/page.php?name=%1 [P]

    but would give me internal error..

    Peace,
    Testing 1.. Testing 1..2.. Testing 1..2..3...

Posting Permissions

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