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
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=