Reputation: 97
I am having issues writing the .htaccess for Apache to rewrite a couple of URLs.
So, one of the cases is:
URL: http://localhost/openhoney/google/4/Laura%20Neiva
Rule: RewriteRule ^openhoney/google/([0-9])/(.*)$ /openhoney/showgoogletrend.php?t=$2&id=$1 [L]
Final: http://localhost/openhoney/showgoogletrend.php?t=Laura%20Neiva&id=4
The case above works properly, but if I try something similar it doesn't work as expected.
URL: http://localhost/openhoney/twitter/1489/Coutinho
Rule: RewriteRule ^openhoney/twitter/([0-9])/(.*)$ /openhoney/showtwittertrend.php?t=$2&id=$1 [L]
Final: http://localhost/openhoney/showtwittertrend.php?t=Coutinho&id=1489
In this last case the "Final" URL works properly, but when I use the "URL", It doesn't work.
Any ideas?
Upvotes: 0
Views: 24
Reputation: 4469
Because ([0-9])
will just match a single number, you can use ([0-9]+)
if you want to match one or more numbers, or ([0-9]{4})
if you want 4 numbers (no more, no less) such like this:
RewriteRule ^openhoney/twitter/([0-9]+)/(.*)$ /openhoney/showtwittertrend.php?t=$2&id=$1 [L]
Upvotes: 1