TheQuestioner
Programmer
I'm having problems with htaccess trying to process a static link into a dynamic link, where the variable value is embedded within the URL HTML page name.
This is how a typical link should look:
Where [tt]flux_capacitor_[/tt] is the name of the widget (and can be called anything), and [tt]114[/tt] is the ID of the widget.
I'm only interested in the widget ID. I need to extract it and redirect to:
So basically, I need to set up a rule which:-
[ol]
[li]Looks for a number within the HTML page name of the static URL[/li]
[li]Extract only the number and add it into the redirect dynamic PHP after the "id=" part[/li]
[/ol]
I've got as far as this:
But if I change the [tt]product[/tt] to any other text (in the redirect rule as well as the source URL), it stops working.
Please help.
This is how a typical link should look:
Code:
[URL unfurl="true"]http://www.mywebsite.com/flux_capacitor_114.html[/URL]
Where [tt]flux_capacitor_[/tt] is the name of the widget (and can be called anything), and [tt]114[/tt] is the ID of the widget.
I'm only interested in the widget ID. I need to extract it and redirect to:
Code:
[URL unfurl="true"]http://www.mywebsite.com/product_detail.php?id=114[/URL]
So basically, I need to set up a rule which:-
[ol]
[li]Looks for a number within the HTML page name of the static URL[/li]
[li]Extract only the number and add it into the redirect dynamic PHP after the "id=" part[/li]
[/ol]
I've got as far as this:
Code:
#rule to interpret [URL unfurl="true"]http://www.mywebsite.com/product-114.html[/URL]
RewriteRule ^product-([0-9]+)\.html$ product_details.php?id=$1 [NC,L]
But if I change the [tt]product[/tt] to any other text (in the redirect rule as well as the source URL), it stops working.
Please help.