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.
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".