ExuberantArtichoke
ExuberantArtichoke

Reputation: 55

URL Rewriting (PHP & Apache Local Server)

I'm using EasyPHP 14.1 DevServer and I'm currently developping my own website on my computer. I was introduced to a new method called URL Routing/Rewriting today. I found this useful website that generates the lines that I need to add to my httpd.conf file.

(I've double checked and the rewrite module is running)

I tried a quick example, a few ones actually, and none of them worked.

I tried to redirect myself from http://localhost/47.html to http://localhost/site1/showproducts.php?id=47 by adding these lines to httpd.conf

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /site1/showproducts.php?id=$1 [L]

I wanted this link http://localhost/site1/products/47/ to lead to http://localhost/site1/showproduct.php?id=47

I'm fairly new to this, so any help would be appreciated

Upvotes: 1

Views: 134

Answers (1)

Asif Uz Zaman
Asif Uz Zaman

Reputation: 410

Ok just update that,

RewriteEngine On    # Turn on the rewriting engine
RewriteBase /
RewriteRule    ^products/([0-9]+)/?$    showproduct.php?id=$1    [NC,L]    # Handle product requests

This will work.

Upvotes: 1

Related Questions