Results 1 to 1 of 1

Thread: Redirecting ugly URLs to pretty URLs?

  1. #1
    Join Date
    Dec 2008

    Redirecting ugly URLs to pretty URLs?

    Hi -

    I'm not sure if this goes in the PHP section, so if someone knows where I should post this, please feel free to tell me.

    I am trying to change my 'ugly' URLs into 'pretty' URLs. To do this I am using .htaccess and mod_rewrite.

    What I want to accomplish is change all of my links that look like this:

    to something like this:

    That part is easy as I use a Rewrite rule like this:

    RewriteRule ^([a-z0-9]+)/[get]+/([0-9]+)\.html $1.php?act=get&id=$2 [L,NC]
    However, since my site is indexed I am concerned about both the pretty and ugly URLs working. I'd like to redirect the ugly URLs to the pretty URLs. This is turning out to be fairly difficult.

    I think I need to do something like this:

    RewriteCond %{QUERY_STRING} ^act=get&id=([0-9]+)$
    RewriteRule ^/([a-z0-9]+).php$ http://www.domain.com/test/$1/get/$2.htm? [L,R=301]
    note that I am doing this in a 'test' folder in my public_html folder. The .htaccess file is in the test folder, so that should not be an issue, correct? Could using a RewriteRule to turn the ugly URL into a pretty URL and then another RewriteRule to change the ugly one into the pretty one cause problems? This does seem somewhat circular... Does the order of the RewriteRules matter? Should one rewrite rule appear before the other in the .htaccess file?

    what am i doing wrong with my rewrite rule? any suggestions on getting the ugly url to redirect to the pretty url?

    Last edited by zenthoef; 01-24-2009 at 11:52 PM.

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