Serve images from subdomain in Wordpress - sql

to give you some context with where I'm at, I have set up a subdomain to serve the images for my site on www.images.mysite.com
This "images" subdomain is intended to serve the images to primary domain www.mysite.com (being located on the server at "/public_html") and also the Woocommerce subdomain www.shop.mysite.com (being located on the server at "/public_html/shop").
I have uploaded the images from the old directory (which is currently still in use) on the server at "/public_html/wp-content/uploads" to the new directory connected to the www.images.mysite.com subdomain at "/public_html/images/wp-content/uploads"
The challenges I'm facing at this stage is that I can't seem to get the images to upload to the www.images.mysite.com location when sent from the www.mysite.com Wordpress installation or the www.shop.mysite.com Wordpress installation even after adding the path for this to 'options.php' for both the www.mysite.com Wordpress installation or www.shop.mysite.com Wordpress installations.
When I did set this path earlier though 'options.php' (through www.mysite.com/wp-admin/options.php pointing to www.images.mysite.com without the trailing slash) it caused conflicts with the www.mysite.com and www.shop.mysite.com sites and dropped all the images from both the www.mysite.com Wordpress installation and the www.shop.mysite.com Wordpress installations. When I removed the path from the ‘options.php’ file the installations both worked fine again.
I have had the process of setting this up explained to me as:
*Imagine you want the images for www.shop.mysite.com to be loaded from www.images.mysite.com The document root folder for www.shop.mysite.com is /public_html/shop - for the images it's /public_html/shop/wp-content (Note: I think this is supposed to be /public_html/images/wp-content but correct me if I'm wrong).
In such case, we need to change the document root for www.images.mysite.com to that one -> public_html/shop/wp-content. Once done, inside the wp-config.php for www.shop.mysite.com, you would need to add the following code: define("WP_CONTENT_URL", "http:// images.mysite.com"); define("COOKIE_DOMAIN", "shop.mysite.com"); Once done, from phpmyadmin, in the database for www.shop.mysite.com (XXXXXX21_wp451) -> there is a tool named SQL at the top where you can run queries. This would be the needed query -> UPDATE wp_posts SET post_content = REPLACE(post_content,'www. shop.mysite.com/wp-content/','images.mysite.com/')*
The explanation above seems a bit out to me with the note I added as bolded.
I'm running HTTPS - should the code above state that?
There are some spaces in what I have been provided here that I'm not sure if they will have an impact on the execution.
I have a dummy site that I can use which won't cause any major issues if I break it which i'll test this in. If anyone has any pointers they would be greatly appreciated :)

take a backup for your database and files and do as this article explains:
Login to your hosting account and launch “phpMyAdmin” section under cPanel. Open the database of your main domain. Select “wp-options” table and replace the following two parameters and save your settings.
upload_path ==> directory root for your subdomain
upload_url_path ==> actual URL path for your subdomain
Until this step there will be no impact on your live site since the existing media upload folder is not changed. Any new image you upload henceforth will be stored in a new subdomain path you have entered in the “wp-options” table. You can cross check this by uploading a test image and check the URL. Once you modified the upload path in “wp-options” table you can see the upload path options are enabled in WordPress admin frontend under “Settings > Media“. Henceforth you can update the uploads file path directly here.
then you will have to replace images links by running this SQL query:
UPDATE wp_posts SET post_content = REPLACE(post_content,'URL of current media folder','URL of new media folder')

Related

Different virtual hosts for same website but different pages

My web server directory is as follows:
var/www/html/site-part-1
var/www/html/site-part-2
In site-part-1, I have a wordpress installation, and when a person lands on my site by google organic / direct whatever when they type in the domain into addres bar it will take user to site-part-1
Currently site-part-1 is operational with the virtual host configuration directory root directory set to var/www/html/site-part-1
But I have a completely different system in site-part-2, that is built with python which I will be accessing via a link from the wordpress site.
example.com (site-part-1) will have a link, and it will take the user to my website example.com/my/directory and in /my/directory will be the contents of site-part-2
It may have worked sticking site-part-2 in the wordpress site folder but for cleanliness I put it into seperate folder
Does anyone know how I should go about setting up my apache settings so that both directories work together?

prestashop not changing base url

I have an installation of prestashop 1.6 on a domain www.mydomain.com and a virtualhost on a server for redirecting to the prestashop/public_html folder. This is my main website working perfect.
Now i would like to clone the installation in another folder prestashop/clone_html and i created an alias on the virtualhost from www.mydomain.com/clone to prestashop/clone_html
Now if i access the clone website the frontend is not working, i get a 404 error and all the links are pointing on the main domain
I tried to change settings.inc.php change the base URI on the database and delete both .htaccess and cache but the links are never changing.
I think maybe the problem is coming from multilanguage redirect?
Do you have any idea what i should try to change?
Thanks
That is a good one! If you want to change the URL of the store and you have already migrated the contents (so no access to the admin is possible or you don´t want to bother), you may do the change directly at the PS table where this information is kept. The name of the table is <prefix>shop_url. Once you access it, the content is self explanatory. You have to play with domain or domain_ssl and then with physical_uri.
Also, using a subdomain as has been suggested in a comment may be a good idea. Depending on your hosting, you may be able to define a subdomain and make it point to a subdirectory. This keeps the physical_uri to / and may avoid other potential problems.

Contao is redirecting to non existend development subdirectory

Im currently trying to move a website to production that has been designed using contao. The website has been developed in a subdirectory of the current website. Now when I change the DocumentRoot to the contao directory the application automatically forwards me to the /development directory which in that situation does not exist anymore.
I did a database dump and searched it for "/development" to find the variable that is storing this information but I didn't find a match. I then did the same with the configuration files but it didn't show up any results too. How is redirecting handeled in contao?
It sounds like your pathconfig.php is wrong. After deploying/moving a Contao installation, you should always execute and log into the Install Tool under contao/install.php. This will correct your pathconfig.php.
Also make sure the RewriteBase in the .htaccess is set to the correct value (probably / in your case).

Migration to VPS w/Plesk

I had a shared hosting package with 1and1 and I just moved over to their VPS hosting that uses Plesk. I already had the domains moved over the VPS server and I already uploaded all of the files via FTP.
I talked to an agent yesterday and he helped me setup the main page on the website so that it would go to the appropriate root directory. The main website is working properly whenever I go the main domain name, however, whenever I go to website.com/blank or website.com/stuff, I receive a 404 error.
The strange part is that I see the files in Plesk file manager, I just don't know why they are not displaying properly. I didn't change anything in the migration process.
I did not change the code on any of the pages and I have contacted their customer support team a number of times, but they have been unable to resolve the issue.
Can anyone tell me what I should do to make sure that the files are associated with the correct pages?
Have you checked the permission for the files and folder under your domain, this seems to be an issue with either your ownership or permission of the files. And if thats not the problem it could even be your .htaccess file.. make sure you have transferred your .htaccess file as well from old shared hosting to new VPS.

Redirect forum address phpBB3

I've created a forum using phpBB3,
The address I got is : http://<FORUM NAME>.com/phpBB3
I would like to change it to http://<FORUM NAME>.com (without the phpBB3)
Is it possible to create another forum addressed to the second URL I mentioned, that uses the same SQL database as the first forum?
The /phpbb3 part of the URL refers to the directory on the server that your forum is installed in. If you move all of the folders and files out of the phpbb3 directory into your websites root directory (usually either htdocs or public_html) then the URL will then become http://<FORUM NAME>.com This is best done via FTP and not your hosts file manager to help prevent corruption of any files.
Only do this if you don't already have pages at http://<FORUM_NAME>.com otherwise you will overwrite anything already there that share any file names.
If you do move everything, once finished log into your phpBB admin control panel and under 'Server configuration -> Server settings' make sure 'Force server URL settings' is set to 'No' and all the internal links on your board will adapt themselves to the new URL.
IMPORTANT! Before you do ANYTHING make sure you download a backup of the files and the database, then if anything goes wrong you can easily put things back again.