1

I would like to know how to create a vanity url for a website.

Ideally I would like to be able to put this on a flyer:

www.charity.org.uk/monthlydonation

and when that is entered, it will go off to:

www.charity.org.uk/donate/monthly-donation.php

I've been reading about vanity urls, redirects and rewrites but quite frankly I'm not even sure what I need to do this?

I tried the following in a .htaccess file:

RewriteEngine On
RewriteBase /

RedirectMatch 301 /monthlydonation /donate/monthly-donation.php

but got an error message saying there was a redirect loop.

All time and help is greatly appreciated.

Johnny
  • 553
  • 1
  • 10
  • 27

1 Answers1

2

Try using mod_rewrite instead, RedirectMatch is part of mod_alias and processes the request separate from mod_rewrite:

RewriteEngine On
RewriteBase /

RewriteRule ^monthlydonation$ /donate/monthly-donation.php [L]

Additionally, the reason why you're getting a redirect loop is that RedirectMatch expects a regex and not just a path. So /monthlydonation is the matching pattern, and that happens to also match the redirect's target: "/donate /monthly-donation.php".

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • Thanks very much for your help with this. That works perfectly. Can you recommend any sites which have good tutorials for this type of stuff? – Johnny Sep 10 '15 at 16:17