1

I have installed Wordpress by downloading the latest version of Wordpress, installing WampServer (64 bit), setting up the DB, and successfully got through the famous 5-minute installation. This all worked. This is all on localhost.

Now, however, I want to work on a different website that was sent to me as a zip file. This zip file included the wordpress folder and the SQL file to import the DB stuff. I pasted in the wordpress folder as "wordpress2" into the www directory and imported the database in through PHPMyAdmin. I edited the wp-config.php file to use the imported database name, root, and the password for root. However, when I go to localhost and select wordpress2 from the list of projects, Chrome simply downloads a file while showing me a "This site can't be reached" page. What do I need to do to make this work? If it's not possible to have multiple projects within the www folder, that's ok, I just need to get this one site working so that I can work on it.

Edit Ok so I think I've found the problem. This site was given to me by a client to work on. Inside their .htaccess file, it looks like the below. I think the problem is that localhost can't find index.php (or any file, for that matter) because it is getting "porterp6" added onto the URL. How can I temporarily modify this and still have it working for when I send this back to the client?

# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /~porterp6/
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~porterp6/index.php [L]
</IfModule>

# END WordPress
  • is your localhost site reachable? If your "wordpress2" folder exists in "wamp/www/" and if you can see the localhosthome page after starting wampserever correctly, and still you cant access your projects, then simply go to www folder, open index.php and search for $suppress_localhost and set its value to false. Restart wampserver – Pat_Morita Jan 16 '18 at 21:29
  • Looks like the index.php file does not contain this line of code. In addition, I did a search for "suppress_localhost" in all files within the wordpress folder and there were no hits. – whatwhatwhat Jan 16 '18 at 21:51
  • Yes, localhost is reachable. Right now I'm trying to get the regular wordpress site (initial installation) to work because it is no longer working. – whatwhatwhat Jan 16 '18 at 21:52
  • You can just delete the htaccess file and generate your own by visiting the admin permalinks page. Your client doesn't need your htaccess file when you pass the project back. The AddHandler directive may be causing an issue, typically when php files get downloaded it's because the server doesn't know what to do with that file extension. – Milo Jan 17 '18 at 3:48
  • Have you tried copying the .htaccess file and then renaming a copy ".back" and changing the existing copy to remove the line 2 handler and the rewrite base and line 11 RewriteRule to be /wordpress2/ ?? – Craig Lambie Jan 17 '18 at 5:39
2

What I do

  1. On receipt of Wordpress files and Db install in my localhost directory (I use EasyPHP Dev server)

  2. I then install Db and change wp-config.php to connect to local db etc.

  3. Then copy .htacces to htaccess.back

  4. Edit .htaccess to point at local dir structure (in this case find "~porterp6" and replace with "wordpress2"

  5. Edit the wp-config.php file in your local directory with

    define('WP_HOME','http://localhost/wordpress2/'); define('WP_SITEURL','http://localhost/wordpress2/');

  6. In this case, also comment out the handler (line 2)

Your .htaccess would look like this

# Use PHP5.4 as default
#AddHandler application/x-httpd-php54 .php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /wordpress2/
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress2/index.php [L]
</IfModule>

# END WordPress

Afterwards

After you have done the work you need to do

  1. Zip all the files in wordpress2 dir up
  2. Enter the zip and
  3. Delete the .htaccess from the zip
  4. Rename htaccess.back to .htaccess
  5. Comment out the wp-config.php manual site location entries like this:

    #define('WP_HOME','http://localhost/wordpress2/'); #define('WP_SITEURL','http://localhost/wordpress2/');

You are ready to send back to the client - how to automate that last part - is a different question - how to remember to do it when you send it over in future - another question - form a habit of checking it is how I handle that.

  • I edited the .htaccess file to what you've written above, but now the site keeps redirecting to something like http://[some-ip-address]/~porterp6/. It's almost as if somewhere in the code the .htaccess file is being bypassed/ignored. Do you know what might be causing this or what I can investigate? – whatwhatwhat Jan 22 '18 at 23:46
  • It looks like the home and siteurl values in the database were set to http://[some-ip-address]/~porterp6/. I've changed these to http://localhost/wordpress2/index.php. Do I need to modify the temporary .htaccess file in any way as a result of this? – whatwhatwhat Jan 23 '18 at 0:34
  • 1
    Ah yes, that is also required. I usually don't change the db, but add these entries into the wp-config.php file codex.wordpress.org/Changing_The_Site_URL define('WP_HOME','http://localhost/wordpress2/'); define('WP_SITEURL','http://localhost/wordpress2/'); then you can easily comment it out. I will edit my answer to reflect the extra step – Craig Lambie Jan 25 '18 at 11:14
  • Looks like the site still won't load. It just shows an empty blank screen when I enter in http://localhost/wordpress2/index.php. – whatwhatwhat Jan 29 '18 at 1:07
  • sorry for delay @whatwhatwhat I have been travelling, did you sort this out? I just re-read my comment, and realised that I might have been confusing, you do not need to edit the .htaccess file any further no. - did you edit that? – Craig Lambie Feb 3 '18 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.