I've got a page www.mypage.com and I want to redirect specific URL to another URL that does not exist.
For example, I want www.mypage.com/about
to redirect to www.mypage.com/about-company.php
, where /about does not exists - it's a custom URL written by me.
I've got no dynamic URL, only want to tell through .htaccess
"this /CUSTOM_URL redirect to this /URL.php".
In the URL bar, it must show the custom url.
I don't know if it can be done. I've looked for it and all I've found are ways to rewrite dynamic URL and so, with patterns.
An example of that, would be the Permalinks of Wordpress, where you can specify which URL you want for each page.
Try adding the following to the .htaccess
file in the root directory of your site to get the specific example you requested to work: to access www.mypage.com/about-company.php
by using www.mypage.com/about
.
RewriteEngine on
RewriteBase /
#if about was requested, server about-company.php
RewriteRule ^about$ about-company.php [L,NC]
If you wanted a more general rule e.g. www.mypage.com/anything
is used to access
www.mypage.com/anything.php
you could replace the rule above with
RewriteRule ^(\w+)$ $1.php [L,NC]
Or you could have all requests to to a single .php file that decides what page to display e.g.
RewriteRule ^(\w+)$ index.php?page=$1 [L,NC]