简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM