imperium2335 Posted February 26, 2013 Share Posted February 26, 2013 I am trying to create a rewrite rule that will let me keep the following URL clean: <script type="text/javascript" src="http://www.mysite.com/views/Page/js/jsfile1.js"></script> To be: <script type="text/javascript" src="http://www.mysite.com/js/jsfile1.js"></script> When I want to include JS and CSS files in any given view, I call: $this->view->js = array('Page/js/jsfile1.js', 'Page/js/jsfile2.js') ; Where Page would change according to the controller you are currently in. E.g. If I am on www.mysite.com/contact, any JS I load be redirected to: www.mysite.com/views/contact/js/jsfile1.js But in the header of my contact page you would only see: <script type="text/javascript" src="http://www.mysite.com/js/jsfile1.js"></script> How can this be done? Or does someone know of a better way to not expose the system directories such as /views etc in a PHP MVC framework (this is my own mini custom framework BTW)? I hope I'm making sense! Quote Link to comment https://forums.phpfreaks.com/topic/274965-use-part-of-the-url-in-a-rewrite-in-php-mvc/ Share on other sites More sharing options...
imperium2335 Posted February 27, 2013 Author Share Posted February 27, 2013 **BUMP** Quote Link to comment https://forums.phpfreaks.com/topic/274965-use-part-of-the-url-in-a-rewrite-in-php-mvc/#findComment-1415320 Share on other sites More sharing options...
Christian F. Posted February 27, 2013 Share Posted February 27, 2013 You cannot have the web-server magically know which folder to go into, it has to get that information from the client. After all, how would the server know that one call to /js/display.js actually means [/ic]/thread/js/display.js[/ic], but another (identical request) actually means /post/display.js? Also: The referrer is not reliable, a lot of people have it turned off in their browser, or have it modified by proxies etc. Quote Link to comment https://forums.phpfreaks.com/topic/274965-use-part-of-the-url-in-a-rewrite-in-php-mvc/#findComment-1415345 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.