Associate
I'm trying to rewrite 3 URLs, but because the 1st and 2nd rule have the same pattern, the 2nd rule is never reached, and so music.php is served in the browser, instead of music2.php.
Original URLs:
https://example.com/music.php?title_url=example-string
https://example.com/music2.php?country=england
https://example.com/music2.php?country=england®ion=staffs
Relevant mod_rewrite rules in htaccess:
Result I want:
https://example.com/music/example-string
https://example.com/music/england
https://example.com/music/england/staffs
Is there a way of adding a prefix or suffix to the "title_url" parameter of the first URL, to distinguish between the first and second patterns in my htaccess, without that prefix or suffix appearing in the URL that displays in the browser? E.g. every title_url would end with 999 (the title URLs may contain numbers, so I can't use a number alone to identify):
https://example.com/music.php?title_url=example-string999
The rewrite for that should display:
https://example.com/music/example-string
The following can be used to remove 3 number 9s, but I've no idea if it's possible to combine it with the other rule that affects title_url:
I'll be extremely grateful for any solutions. If this isn't possible, maybe there's another way around it?
Original URLs:
https://example.com/music.php?title_url=example-string
https://example.com/music2.php?country=england
https://example.com/music2.php?country=england®ion=staffs
Relevant mod_rewrite rules in htaccess:
Code:
RewriteRule ^music/([a-zA-Z0-9-]+)$ music.php?title_url=$1
RewriteRule ^music/([a-zA-Z0-9-]*)$ /music2.php?country=$1
RewriteRule ^music/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)$ music2.php?country=$1®ion=$2
Result I want:
https://example.com/music/example-string
https://example.com/music/england
https://example.com/music/england/staffs
Is there a way of adding a prefix or suffix to the "title_url" parameter of the first URL, to distinguish between the first and second patterns in my htaccess, without that prefix or suffix appearing in the URL that displays in the browser? E.g. every title_url would end with 999 (the title URLs may contain numbers, so I can't use a number alone to identify):
https://example.com/music.php?title_url=example-string999
The rewrite for that should display:
https://example.com/music/example-string
The following can be used to remove 3 number 9s, but I've no idea if it's possible to combine it with the other rule that affects title_url:
Code:
9{3,}
I'll be extremely grateful for any solutions. If this isn't possible, maybe there's another way around it?
Last edited: