I've a domain and a subdomain with this structure:
Domain: mydomain.com
Subdomain: m.mydomain.com (which "mydomain.com/mobile/" is the folder)
While I'm on mydomain.com, I upload images to the folder "images", this is the structure:
mydomain.com/images/image.jpg
And I've no problems with it, because the folder /images/ is in the domain.
Now, when I'm in m.mydomain.com, how can I upload images to the domain folder (mydomain.com/images) and not to the subdomain folder (m.mydomain.com/images)?
Thank you guys
PS. I'm using Routing with both domains, with the index.php as "router"
Since m.domain.com is in domain.com you can use m.domain.com/images for both.
Use the same directory for both domains and use .htaccess to route the mobile to index.m.php or something like that in the same directory.
More complicated. You can serve files through a url page built in php. Basically just a page that takes the file name searches for it in the server directory outside the site and dumps the content with appropriate headers.
Similar to 2 you can route both mobile and normal to the same directory. Detect in index.php if the subdomain is specified and load the site files from your mobile folder. This is my preferred method.
Related
I have the site domain.com and creates the need subdomain.domain.com that points to the directory domain.com/public_html/subdomain
How do I do that?
The subdomain folder must be within the public_html folder domain.com
The vestaCP possesses the possilidade to choose the root folder of the subdomain?
Sorry for my bad English.
Simply put:
I need it:
sub.domain.com> /home/user/web/domain.com/public_html/subdomain
No:
sub.domain.com> /home/user/web/sub.domain.com/public_html
I always solve it by one of this 2 ways (each of them has advantages and disadvantages):
I redirect the subdomain by .htaccess file to the folder inder the main domain. So i just add Redirect 301 / http://example.com/subfolder to the .htaccess file of subdomain. It's classic unmasked redirection.
I make a PHP file index.php in /home/user/web/sub.domain.com/public_html folder with this content: <?php print file_get_contents("https://example.com/subdomain/"); ?> and in folder /home/user/web/example.com/public_html/subdomain is website. Phe PHP file displays the whole content of website on main domain folder.
None of them is the real solution, it's just a how to hack it, but I hope it will be useful
Lets say I have the website url www.example.com. My index.php page is in the root directory. I then want to have a page at www.example.com/someDir as well as a page at www.example.com/someDir/anotherDir. I thought that I would make the directory someDir in the root directory and make the directory anotherDir within the directory someDir, then place an index.php page in both those new directories which would be the visible page at those URLs.
Is this the proper way?
Yes.
Note that your web server (apache or whatever) should redirect www.example.com/someDir to www.example.com/someDir/ (with a trailing slash) which will make the relative links work correctly with respect to the index.php files.
I have two domains.
Www.abc.com
Www.xyz.com
Now, I have one domain hosted at my cloud server, which is www.abc.com
And I have a folder in www.abc.com = www.abc.com/appFolder/app1/
Now I have hosted my another domain at the same cloud server using virtual host configuration in apache with document root folder for this domain to point out: at the above folder.
So basically when somebody is going to www.xyz.com then they are viewing the page at www.abc.com/appFolder/app1/
My problem is, I have database connection config file situated at the root folder, i.e. At www.abc.com So this is why when I go to my abc.com everything works fine. But now in case of xyz.com it is unable to find the config file??
How i can use config file there?? Also in case of accessing the image.
If I am in abc.com then I can access file by doing ../../image.jpg but in case of xyz.com it is not able to find the image file by doing this. I understand it is because of different document root folders. But is there any way that I can deal with this issue??
It should not change anything for your database connection. Config files are accessed with local paths. They are not related to domains.
For images, you could use absolute url and load images on www.abc.com even if users are on www.xyz.com. Or, you can detect url in request prameter and adjust paths. A simple in the header can define base url for all links in your page.
A website that I work on has many directories that are each websites of their own. The idea is that when someone visits the website like this: http://www.foo.com/bar that the index.html / index.php for each bar (and whatever other files are needed to display it) are shown to a client.
The main website (foo.com) has its root directory in the /www/... path. The files for the main website are all at the website's root directory.
At the moment all of the bar directories are in the /docs/... path which is not normally accessible by visiting the website. However, there are symbolic links at the website's root directory for each bar that go to the appropriate /docs/... path.
Although this works, I would prefer not to have a symbolic link for each bar in the website's root directory.
What I would prefer to do is have a PHP script (or another kind of script if necessary) that determines if some bar exists in the /docs/... path and if it does display that to a client without all the symbolic links.
Is this possible and if so is it possible to do without making the URL appear to be different to a visiting client?
Apache alias is the answer, its much like a symbolic link allowing Apache to access directories outside of the web root as if they were inside the webroot
Alias /foo /bar
Alias Directive
ok so i have 2 domains
site1.com/images/ (all images)
and I need to redirect the imgages link site1.com/images/ to site2.com/images/ so that when
and when exp. site1.com/images/i.jpg is called it will look at site2.com/images/1.jpg and will find it.
.this is basic duplicate of the site and i don't want to move images back and forward.
Put in your .htaccess on site1.com
Redirect permanent /images http://sites2.com/images
If the websites are on the same server and running under the same user, you could use symbolic links between both websites.
E.g., create a symlink to /home/site2/public_html/images in /home/site1/public_html/images. Another option is using the Apache's Alias directive:
Alias /images /home/site2/public_html/images
Put this in the vhost config of site1.
Using redirection on Apache:
RedirectPermanent /images http://site2.example.com/images
The best way would probably fixing the HTML code pointing to one domain. If you cannot decide which domain should get the static content, create a subdomain (or even a different domain) to store the files.