PHP url functions and subdomains

∥☆過路亽.° 提交于 2019-12-03 00:40:21

I am not sure if this is something you might be interested in, but you could always create a new subdomain and call it something like style.[domain] and create a new variable in your config file and point it to that. this way you have all the images and css files etc stored in one place and if your traffic spikes you can always move that subdomain to a CDN etc so its really customizable.

UPDATE

ok so you can simply use a new variable in your config file like below :

$_config['http'] = 'http://www.yousite.com/';

now you can just use this variable to point to all your downloads etc on the main site rather than each pointing to the subdomain's folder. and if you want to be more flexible you can also add a few more css or js folders like :

$_config['http'] = 'http://www.yousite.com/';
$_config['css'] = $_config['http']."css";
$_config['js'] = $_config['http']."js";

the solution above will also help you if you decided to move the files around or just move a certain folder around etc. this is a good practice if you can adopt it.

You might be able to use an alias in htaccess (or the server config) :

Alias /images /home/username/public_html/images

If that's not possible, you could rewrite all requests to /images via htaccess:

# Untested - should get you on the right track though
RewriteEngine On
RewriteRule ^/images/(.*)$ http://yourdomain.com/images/$1 [R=301,L]
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!