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

9
  • What you are looking for is mod_rewrite Commented Nov 25, 2016 at 17:27
  • does your framework currently use rewrite rules to send pretty url requests to a controller? Commented Nov 25, 2016 at 17:29
  • @ManuelMannhardt Wouldn't it be an "undesirable" effect, if users of my framework HAVE to edit their .htacccess file? Commented Nov 25, 2016 at 17:29
  • They dont have to if you set it up properly Commented Nov 25, 2016 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. Commented Nov 25, 2016 at 17:30

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.