Jeffro Posted September 23, 2011 Share Posted September 23, 2011 I've been messing with this for the last hour... visiting about 20 different Google tuts and I can't seem make my site rewrite the url in any way. I've even just tried changing .php to .html and I'm not having any luck. Here's one of my many fails: RewriteEngine on RewriteRule viewItem(.*)\.htm$ /viewItem.php?id=$1 For this one, I'm just trying to change my viewItem.php page to viewItem.html My ultimate goal is to change http://mydomain.com/viewItem.php?id=900 (as one example of an id) to http://mydomain.com/details/ I'm then going to append the title on the end. I can do that in php but being a newb to .htaccess, I'm apparently missing something glaringly obvious. Any ideas? Thanks much. Quote Link to comment https://forums.phpfreaks.com/topic/247685-i-cant-get-my-url-to-rewrite-anything/ Share on other sites More sharing options...
cags Posted September 23, 2011 Share Posted September 23, 2011 Step 1: make it work in the format /viewItem.php?id=$1 (I'm assuming you've done this). Step 2: make a rewrite rule that matches your 'pretty' url and redirects it to the other one correctly Based on what you've posted, I'm going to assume that /viewItem.php?id=1 is accessible via viewItem1.htm, so you would do something like... RewriteEngine On RewriteRule ^/?viewItem[0-9]+\.htm$ /viewItem.php?id=$1 If typing /viewItem1.htm in your address bar shows the correct page, Step 2 done. Step 3 : update links on your site to point at the new urls Update all the links on your site so that they read in the pretty format SEF format rather than the old query string. Step 4 : party I'm assuming you know how to do this. Quote Link to comment https://forums.phpfreaks.com/topic/247685-i-cant-get-my-url-to-rewrite-anything/#findComment-1271996 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.