Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: .htaccess help needed - dynanmic redirect

  1. #1
    DomainMagnate's Avatar
    DomainMagnate is offline Super-Duper Moderator
    Join Date
    Dec 2008
    Posts
    749
    Blog Entries
    2
    Thanks
    150
    Thanked 175 Times in 110 Posts

    .htaccess help needed - dynanmic redirect

    Hey all!

    Need some help to redirect the old file structure to new, several lines:

    old: site/default.php?page=uk01
    new: site/txt/uk01.php

    old:site/default.php?page=us01
    new:site/txt/aus01.php


    01 means there are many pages like this with 01, 02, 03- - so it can be replaced with any expressoin

    Please post the .htaccess file I should use to redirect the old queries to new pages

    thanks!

  2. #2
    Aziz's Avatar
    Aziz is offline no investment, no glory
    Join Date
    May 2009
    Location
    IL
    Posts
    736
    Thanks
    588
    Thanked 243 Times in 168 Posts
    .htaccess code
    Code:
    RewriteEngine On
    RewriteRule ^txt/([^/]*)\.php$ /default.php?page=$1 [L]
    Original URL example:
    http://example.com/default.php?page=uk01

    The rewritten URL example:
    http://example.com/txt/uk01.php

  3. #3
    chetan's Avatar
    chetan is offline PHP Coder
    Join Date
    Mar 2009
    Location
    India , Nagpur
    Posts
    74
    Thanks
    3
    Thanked 6 Times in 5 Posts
    Quote Originally Posted by Aziz View Post
    .htaccess code
    Code:
    RewriteEngine On
    RewriteRule ^txt/([^/]*)\.php$ /default.php?page=$1 [L]
    Original URL example:
    http://example.com/default.php?page=uk01

    The rewritten URL example:
    http://example.com/txt/uk01.php


    Thanks Got a Good Example
    Visit : Paste-Bin | Yahoo Tracer | Twitter Signatures
    Contact Me For PHP Works
    An cURL Expertise

  4. #4
    DomainMagnate's Avatar
    DomainMagnate is offline Super-Duper Moderator
    Join Date
    Dec 2008
    Posts
    749
    Blog Entries
    2
    Thanks
    150
    Thanked 175 Times in 110 Posts
    hm just tried it, but it doesn't work for some reason

  5. #5
    chetan's Avatar
    chetan is offline PHP Coder
    Join Date
    Mar 2009
    Location
    India , Nagpur
    Posts
    74
    Thanks
    3
    Thanked 6 Times in 5 Posts
    Try Using this code
    Code:
    RewriteEngine On
    RewriteRule ^txt/([a-zA-Z0-9.*?).php default.php?page=$1
    Save in htaccess at the root of site and please confirm that RewriteMod is Enabled with server
    Visit : Paste-Bin | Yahoo Tracer | Twitter Signatures
    Contact Me For PHP Works
    An cURL Expertise

  6. #6
    Aziz's Avatar
    Aziz is offline no investment, no glory
    Join Date
    May 2009
    Location
    IL
    Posts
    736
    Thanks
    588
    Thanked 243 Times in 168 Posts
    you need to enable the Rewrite engine in Apache

    httpd.conf
    Code:
    LoadModule rewrite_module modules/mod_rewrite.so

  7. #7
    DomainMagnate's Avatar
    DomainMagnate is offline Super-Duper Moderator
    Join Date
    Dec 2008
    Posts
    749
    Blog Entries
    2
    Thanks
    150
    Thanked 175 Times in 110 Posts
    chetan, your code gives a 500 error.
    it's on a shared hostgator account, so I think they should have it enabled, will check it

  8. #8
    chetan's Avatar
    chetan is offline PHP Coder
    Join Date
    Mar 2009
    Location
    India , Nagpur
    Posts
    74
    Thanks
    3
    Thanked 6 Times in 5 Posts
    Yes 500 Misconfiguration Error is Coming on Hostgator

    Try this Simple Code this will work for sure

    Code:
    RewriteEngine On
    RewriteRule txt/(.*).php default.php?page=$1
    Visit : Paste-Bin | Yahoo Tracer | Twitter Signatures
    Contact Me For PHP Works
    An cURL Expertise

  9. #9
    DomainMagnate's Avatar
    DomainMagnate is offline Super-Duper Moderator
    Join Date
    Dec 2008
    Posts
    749
    Blog Entries
    2
    Thanks
    150
    Thanked 175 Times in 110 Posts
    still no effect.. I have the urls with /site/, so I just added site/ to both paths, dont think that could be a problem?

  10. #10
    chetan's Avatar
    chetan is offline PHP Coder
    Join Date
    Mar 2009
    Location
    India , Nagpur
    Posts
    74
    Thanks
    3
    Thanked 6 Times in 5 Posts
    Yes

    Code:
    RewriteEngine On
    RewriteRule /txt/(.*).php /default.php?page=$1
    Hope this will work [-o<
    Visit : Paste-Bin | Yahoo Tracer | Twitter Signatures
    Contact Me For PHP Works
    An cURL Expertise

Page 1 of 2 12 LastLast

Similar Threads

  1. .htaccess All Page Redirect
    By ProxySites.ca in forum Managing
    Replies: 7
    Last Post: 28 May, 2010, 22:52 PM
  2. .htaccess / redirect to 'www.'
    By Snak3 in forum On-Site SEO
    Replies: 12
    Last Post: 30 December, 2009, 19:13 PM
  3. .htaccess
    By dodolls in forum Managing
    Replies: 6
    Last Post: 15 November, 2009, 06:58 AM
  4. Quick redirect help needed
    By DomainMagnate in forum Managing
    Replies: 10
    Last Post: 2 May, 2009, 21:08 PM
  5. .htaccess - How to properly redirect a domain?
    By Shenron in forum Programming
    Replies: 10
    Last Post: 9 January, 2009, 08:30 AM

Tags for this Thread

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
  •