0

How can I redirect if in URL exist /hr or /en to subfolder hr or en but URL to stay same?

URL examples:

https://www.example.com/hr/services
https://www.example.com/hr/blog/installing-iis-8
Flegy
  • 47
  • 13
  • It is unclear what you actually ask. Please take the time to revise your question and improve its precision or add information: you are probably asking for a way to "rewrite", not to "redirect", since you want to visible URL to stay unaltered. But what to you mean by "subfolder" here? What subfolder? Where? And why is the `/hr/` in the URL not perfectly fine to enter a subfolder? – arkascha Mar 28 '19 at 00:34
  • Apart from that: there are thousands of answers here on SO explaining how to rewrite request URL for an apache server. If none of all those answers helped you to solve your task then you need to explain why that is, what is different in your case, why the existing answers do _not_ answer your question. Otherwise you only ask us to repeat existing questions which hardly makes any sense. – arkascha Mar 28 '19 at 00:35
  • If I am using root -> subfolder hr so if in URL exist /hr/ to read subfolder hr index.php but URL to stay same. Same as will call subfolder if in URL https://www.example.com/hr/ but I want to read subfolder and if have anything after /hr/ – Flegy Mar 28 '19 at 00:40
  • [Try the solutions from this link:](https://stackoverflow.com/questions/990392/htaccess-rewrite-to-redirect-root-url-to-subdirectory) – NewOnStackoverflow Mar 28 '19 at 07:35
  • 1
    So the actual issue is not rewriting to a folder (which is not required, since the path prefix `/hr/` already targets exactly that subfolder), but that you want to execute a file `index.php` when the folder itself is the target of the URL? That is not even mentioned in your question above... Please take a look at the `DocumentIndex` in the documentation of the apache http server and consolt existing for answers to how to add a "trailing slash" by means of rewriting. – arkascha Mar 28 '19 at 08:49
  • thanks, arkascha, didn't notice it was already redirecting/hr/ folder. How can I make to target index.php if it looks as https://www.example.com/hr/services because it will look index in services folder? – Flegy Mar 29 '19 at 15:18

0 Answers0