-1

I am trying to rewrite this URL

https://example.com/html/mypage

to

https://example.com/mypage

The destination is the same html page, only the displayed URL needs to change.

  • 2
    What have you tried so far and why didn't it work? – Martin Mar 29 '23 at 16:52
  • 1
    There are thousands of questions on Stack Overflow about this almost exact issue and with simply a few minutes of searching you should be able to find your answer. Also there are hundreds of other websites with template guides for how to resolve this issue so please see the linked Q here and read up on how this works. – Martin Mar 29 '23 at 16:55
  • show us the content of your current `.htaccess` did you attempt any redirection? somthing as simple as `Redirect /html/mypage.html /mypage.html` should work. – PA. Mar 29 '23 at 16:55
  • Why do you want to rewrite from a complex URL to a simpler one? Usually rewrites map a simple URL that users see to a more complex URL with URL parameters that is easily digestible by your web framework. I suspect that you actually have what you want backwards. I suspect you want to rewrite the display URL of `/mypage` to get processed by `/html/mypage`. – Stephen Ostermiller Mar 29 '23 at 19:17

1 Answers1

1
RewriteEngine On
RewriteRule ^mypage$ /html/pagename [L]

You can solve your problem by adding the above code lines to .htaccess Replace pagename with the name of the page you want

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
user21520830
  • 121
  • 4
  • That rewrite does the opposite of what they asked for (but this is probably what they actually want.) – Stephen Ostermiller Mar 29 '23 at 19:18
  • This requires the distributed configuration file to be located in the html folder. That should at least be mentioned in the answer. Better even explained or not be required. – arkascha Mar 29 '23 at 19:30