Jump to content

I can't get my url to rewrite anything


Jeffro

Recommended Posts

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.