Wordpress site broken after Apache vhost setting - wordpress

I had a working wordpress site accessible by http://localhost/wp corresponding to the directory /Library/WebServers/Documents/wp. Since I desired to have my wordpress site accessible by http://wordpress without moving the wordpress directory I decided to set a new host in /etc/private/hosts where I added the entry:
127.0.0.1 wordpress
Then I was able to access the site with http://wordpress/wp. To avoid the 'wp' part of the URL I decided to use Apache virtual hosts by adding in /etc/apache2/extra/httpd-vhosts.conf the following block:
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents/wp"
ServerName wordpress
ServerAlias wordpress
ErrorLog "/private/var/log/apache2/wordpress"
CustomLog "/private/var/log/apache2/wordpress" common
</VirtualHost>
Then I restarted Apache and trying to access the site by using the URL http://wordpress I was able to see the written part of the first page but no images and all the links where broken.
Checking out the links I see that the URL they are pointing still contains the 'wp' part I was trying to avoid.
Any suggestion?

Yes, in your database, all of the URLs still have the /wp/ in them. Changing your Apache config did not change this. The easiest way to do this is to use wp-cli (http://wp-cli.org) to do a search and replace on your WordPress database.
BACKUP YOUR DATABASE BEFORE PROCEEDING
wp search-replace 'http://wordpress/wp/' 'http://wordpress/' --dry-run
Assuming you have installed wp-cli and named it wp, the command above will show you all the changes it would make to remove the /wp/. from your URLs.
Once you are happy that it is changing the correct things, remove ``--dry-run` and it will actually make the changes for you.
wp-cli is a powerful tool. We use it for a lot of tasks at http://getpantheon.com and I use it to do a lot of maintenance work on all my personal WordPress sites.
HTH,
=C=

Related

How do I get access to my .htaccess files on Google Cloud for my Wordpress Website?

I migrated a website from one web host to another (which is Google Cloud), but I'm having problems changing my permalinks from plain to post name. I want to have the website show the name of the page on the url, but I can't figure out how to get access to my .htaccess files on Google Cloud to see if this is the cause of it.
The error on the website pages are 404 Not Found. But the pages are found if the permalinks are on plain and not on %postname%.
I'm working on a wordpress file.
I tried to change permalinks to %postname% in the wordpress dashboard, but I received an error. I also tried to see if plugins were an issue but its the permalinks needed to be on "plain" setting.
Access SSH: Go to edit your apache .conf
sudo nano /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride ALL <----(edit from none)
Require all granted
</Directory>
Then restart apache2 using:
sudo service apache2 restart
I had the same issue, I hired someone to move a client site (tenwitch.com) to GCP, and when it is time to adjust some little stuffs. I decided to do it myself only to find out that it is not the traditional cpanel I am used to. What you are going to do is download filezilla (https://filezilla-project.org/download.php) and PuTTY, there are tutorial online to follow. You will be able to set it up instantly.

How to move wordpress website from hosting account to localhost

I'm getting 404 error while accessing relative paths on
Wordpress website copied from hosting and deployed locally as Apache vhost.
Local website is basically git clone of the existing remote website.
The following steps were performed to make it work:
DB urls were searched and replaced using wp-cli to be http://local.webiste.com
VHost configured according to apache documentation.
/etc/hosts modified.
So website can be accessed successfully via http://local.website.com.
Media in http://local.website.com/wp-content/uploads/2017 can be viewed successfully.
Though, accessing a Wordrpess page identified by /relative path (relative to current domain/site) causes "The requested URL /relative/ was not found on this server" error.
I'm using the same .htaccess from the remote public_html folder.
How to achive equivalent to hosting behaviour for local vhost website?
Is .htaccess, apache2 configuration, vhost configurations should be changed?
You can use the WP Migrate DB plugin to fix URLs and PHP paths, and them you need to fix the .htaccess file (PHP path) and maybe wp-config.php.
The solution was to allow using .htaccess in /etc/apache/apache2.conf by changing from AllowOverride None to AllowOverride All.
More about it here
So that section related to my local website now looks like:
<Directory /var/www/local.webiste.com/public_html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Allow from 127.0.0.1
</Directory>
Please take a backup through Wordpress Duplicator/All in one migration plugin
For Duplicator plugin kindly follow that https://wordpress.org/plugins/duplicator/
For All in one migration plugin please follow that https://wordpress.org/plugins/all-in-one-wp-migration/
After backup simply you can create a folder in htdocs folder in xampp then create the database in localhost phymyadmin with same name that you have assign to folder
Then further implementation of the backup you can follow the above links please
You can easily move your WordPress website from any hosting to your local host such xampp or wamp server, etc. Follow these simple steps:
Open your WordPress website dashboard.
Install the duplicator backup plugin.
Once it is installed. Take a backup of all of your database files, themes, plugins, and everything.
Open your localhost Cpanel and upload the backup zip file into public.html folder.
Congrats. You have successfully moved your website.
I hope this information will help you. Thanks

Wordpress Directory Switch Issues

I recently set up a digitalocean account with wordpress pre-installed. When it is pre-installed, the directory structure begins in the root (var/www/html/). I wanted to change this, so i moved the files into a new directory (/var/www/html/viralnewz) and changed the wp-config files to represent this (they no longer point to the http://178.62.87.202/ but instead to viralnewz.co.uk, which in turn will point to viral newz directory (/var/www/html/viralnewz). This is set up with a virtualhost, and works fine for the front-page and the admin. But when i try and view others pages, i get a 404 not found. I'm assuming theres an issue with the wordpress setup because it can't find the correct page, however i'm unclear how to actually solve this issue.
Apache conf file
<VirtualHost *:80>
DocumentRoot /var/www/html/viralNewz/
ServerName viralnewz.co.uk
# Other directives here
</VirtualHost>
Additionals to wp-config.php
define('WP_HOME','http://viralnewz.co.uk/');
define('WP_SITEURL','http://viralnewz.co.uk/');
If i've missed any other information that could be beneficial, please mention it and i'll do my best to find it.
Chris
I think your problem can be related to url values stored in DB.
You can migrate safely using this tool, that permit to find and replace the urls stored in DB.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Can be also necessary update .htacess file: normally is enough enter in permalink settings and save again the structure of permalinks.

What is the best way to implement a blog on a website that uses the Symfony framework?

Our company website was built using the Symfony framework. We want to add a blog to it in a subdirectory (so the website will be www.ourwebsite.com/blog). What is the easiest way to do this?
Ideally, I would like to use WordPress as it is what I am most experienced in, but switching the entire site over to WordPress is not an option. One option is to create a subdomain for the blog (blog.ourwebsite.com) but we are investing a large amount of money into SEO and our website already has decent rankings. We would like to use a blog to further increase the rankings of our website, and I feel that having it in a subdomain would slow us down from reaching our goals based on the limited amount of research I've done.
I would solve this at the webserver level. Suppose the Symfony app lives at /var/www/example.com and the Wordpress blog at /var/www/blog.example.com.
For Apache, something like this should do:
<VirtualHost example.com:80>
DocumentRoot /var/www/example.com
ServerName example.com
<Directory /var/www/example.com>
# Your Symfony config here
</Directory>
Alias /blog /var/www/blog.example.com
<Directory /var/www/blog.example.com>
# Your Wordpress config here
</Directory>
</VirtualHost>
See Alias directive for details. If you get the idea, it should be straightfoward to adapt this to other webservers, such as Nginx, if you're not using Apache.
Or you can just go with: symblog.co.uk if you are willing to go a little more into the code.

Multiple Subdomains on Xampp

I want to start developing a site locally and later port it to the web. As I'm planning to run a Wordpress Network using Subdomains, I would need to set-up a Xampp installation that would allow me to run a subdomain install.
No idea how to do this and haven't found much info on the web either. Can someone point me in the right direction? I've seen people managing to change the URL as well. I can't seem to get past http://localhost.
You need two things first of all, and nothing related to wordpress.
Let´s supose you will use a local url like "your_test_domain.local", so:
#1 Add virtual servers on your xampp httpd-vhosts.conf (xampp\apache\conf\extra\httpd-vhosts.conf).
For example:
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs\your_site_folder"
ServerName your_test_domain.local
ServerAlias your_test_domain.local
<Directory "C:\xampp\htdocs\your_site_folder">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
That means, if you surf to "your_site_folder.local" you will see what´s on the "your_site_folder" folder inside xampp htdocs folder. Right?
#2 and also, you need to edit the hosts file on windows (guess you are using win), that´s on: Windows\System32\drivers\etc\, and add this line:
127.0.0.1 your_test_domain.local
Start apache to take this effect. Same thing for subdomains, you only need to create another virtualhost and another host redirection but for "sub_domain.your_test_domain.local"
So, once you got those things, you also will need some plugin to install on wordpress. I use the Domain Mapping Plugin, that will do the rest, but, that´s another story. Start there and you will learn the rest.
Hope that helps.
Try this link
http://www.howtoforge.com/forums/showthread.php?t=23
also watch out for xampp's root index.php file as it has a redirect in it...

Resources