1

So this issue has probably been brought up a couple of times but I can't seem to find an answer to it.

My goal is to include css, js, asset-files into my php framework. However when calling those files, the path must always be called as the folder structure such as:

<link rel="stylesheet" href="\frontend\web\css\style.css">

Instead of what I would prefer:

<link rel="stylesheet" href="\web\css\style.css">

If there is a way to "trick" PHP into referring files (from a different directory), to the directory I want That way it would never show external users that the website/domain has a subdomain or cms.

My file structure would be as such:

root frontend backend

A subdomain could be anything, but in this case would be frontend.domain.com, but is user dependant and other subdomains can be created dynamically such as backend.domain.com, manage.domain.com.

Any clues on how to achieve this effect would be greatly appreciated

BRO_THOM
  • 824
  • 9
  • 24
  • What you are looking for is mod_rewrite – Manuel Mannhardt Nov 25 '16 at 17:27
  • does your framework currently use rewrite rules to send pretty url requests to a controller? – WEBjuju Nov 25 '16 at 17:29
  • @ManuelMannhardt Wouldn't it be an "undesirable" effect, if users of my framework HAVE to edit their .htacccess file? – BRO_THOM Nov 25 '16 at 17:29
  • They dont have to if you set it up properly – Manuel Mannhardt Nov 25 '16 at 17:29
  • @WEBjuju what my framework currently does is create controller depending on the url, and doesn't send anything to my controller. However, since it's my custom framework anything can be added/modified for the better. – BRO_THOM Nov 25 '16 at 17:30
  • @ManuelMannhardt Some explanation would be appreciated. .htaccess and apache aren't really my forté. – BRO_THOM Nov 25 '16 at 17:30
  • are you currently using any redirects in htaccess or your apache conf files? – WEBjuju Nov 25 '16 at 18:00
  • @WEBjuju at the moment the framework is void of any apache configuration. – BRO_THOM Nov 25 '16 at 20:08
  • i can't figure out your setup. if you can explain your project well enough that it doesn't take a lot of questions, you may indeed receive some assistance that could also be helpful for others. right now, the question itself is surrounded in too many questions. – WEBjuju Nov 25 '16 at 20:36

1 Answers1

1

Probably you using yii2 with advanced template.

If you using Apache you can try Yii2 htaccess - How to hide frontend/web and backend/web COMPLETELY , it may help.

If you using Nginx you can use this example

Community
  • 1
  • 1
  • I'm actually constructing my own framework which leaves a lot more space for expansion and has less internal "mess". However, is there no "PHP-only" to for example include files into a different folder or something similar. – BRO_THOM Nov 25 '16 at 17:45
  • @BRO_THOM You can try rewrite all requests to *.css and *.js to php file (e.g. index php) and write your own rules and use something like readfile() to output file. But it will take more resources and time to return file to user. – Hlib Kuznetsov Nov 25 '16 at 18:02