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:Code:http://www.domain.com/file.php?act=get&id=542
That part is easy as I use a Rewrite rule like this:Code:http://www.domain.com/file/get/542.html
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.Code:RewriteRule ^([a-z0-9]+)/[get]+/([0-9]+)\.html $1.php?act=get&id=$2 [L,NC]
I think I need to do something like this:
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?Code: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]
what am i doing wrong with my rewrite rule? any suggestions on getting the ugly url to redirect to the pretty url?
Thanks!


Reply With Quote
Bookmarks