Why does chrome keep downloading a file instead of running the site?

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

Topic google-chrome url-rewriting permalinks htaccess installation Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.