I’m trying to transform any URL in PHP and add a root folder onto it using regex.
Before:
http://domainNamehere.com/event/test-event-in-the-future/
After:
http://domainNamehere.com/es/event/test-event-in-the-future/
Any ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A simple solution without regex:
EDIT: JavaScript solution is pretty much the same:
Of course, for a live application you should also check if
pactually gets a valid value assigned (that means if the slash is found) because you might have an invalid url in your input or empty string.