1

Using mod_rewrite how can I change the current URL format:

  • From: https://example.com/something/NAME-IN-CAPS/phonebook.xml
  • To: https://example.com/anything/whatever/phonebook.php?name=NAME-IN-CAPS
  • Out of interest why would you want to add the string? most people want to remove it for user experience and SEO. – Simon Hayter Nov 10 '15 at 12:07
  • I want to get the phonebook via the php script, i put the name of the user i want to fetch, but the phone is always trailing any url as /phonebook.xml and thats why I need something like this. – Ismaw34 Nov 10 '15 at 12:11
  • Does the "current URL format" actually return a valid resource? – MrWhite Nov 10 '15 at 14:53
  • No, it does not. – Ismaw34 Nov 10 '15 at 15:35
1

Just take the following example, and rewrite the words something, anything, and whatever to your actual directory names:

RewriteRule something/([-A-Z]+)/phonebook.xml anything/whatever/phonebook.php?name=$1
  • Thanks, that is what i was looking for, i modified a little bit the regex, but its fine. Thanks. – Ismaw34 Nov 10 '15 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.