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
4
  • Out of interest why would you want to add the string? most people want to remove it for user experience and SEO. Nov 10, 2015 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, 2015 at 12:11
  • Does the "current URL format" actually return a valid resource?
    – MrWhite
    Nov 10, 2015 at 14:53
  • No, it does not.
    – Ismaw34
    Nov 10, 2015 at 15:35

1 Answer 1

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
1
  • Thanks, that is what i was looking for, i modified a little bit the regex, but its fine. Thanks.
    – Ismaw34
    Nov 10, 2015 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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