[SalesForce] Setting Visualforce page URL different from file name

How to set a Visualforce page URL that is different from a file name?

At the moment my VF page URLs are the same as the file names:
MyPage.page URL will be /apex/MyPage

How to leave file name as is (for example MyPage.page) but change the URL to different one (for example /apex/YourPage)

Best Answer

One simple solution would be to create a new "dummy" visualforce page with a name you wished ("YourPage") that will redirect user to another page.

Redirect using javasript. Disadvantage of this solution is that a seocond page name appears on the browser url.

<apex:page>
    <script>
        window.location.href = '/apex/MyPage';
    </script>
</apex:page>

The second solution with an apex:include:

<apex:page>
    <apex:include pageName="MyPage" />
</apex:page>

Here a name of the first page ("YourPage") is not disappearing from the URL so this is preferred solution.