Running Laravel 4.2 app from a shared hosting on my localhost, but when accesing localhost I get redirected to original URL

53 Views Asked by At

I am trying to run a Laravel 4.2 app from a shared hosting on my localhost so I can make some changes and the put it back. I am running ubuntu 16.04 apache2 and mysql

I followed this Medium article https://adeyomoladev.medium.com/how-to-deploy-a-laravel-app-using-apache-and-mysql-4910a07f9a0c with moderate success.

I changed all the database connections and every artisan command that generates migrations works on my local database.

The problem is that when I try to access my localhost, it gets redirected to original website url. The /etc/apache2/sites-available/laravel.conf is here:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName laravel.example.com
    DocumentRoot /var/www/html/public_html/
     
    <Directory /var/www/html/public_html/>
            AllowOverride All
            Require all granted
    </Directory>
     
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

My directory structure is as follows:

.
├── app
│   ├── commands
│   ├── config
│   ├── controllers
│   ├── database
│   ├── filters.php
│   ├── helpers
│   ├── lang
│   ├── models
│   ├── public_html.tar.gz
│   ├── routes.php
│   ├── service
│   ├── start
│   ├── storage
│   ├── tests
│   └── views
├── artisan
├── bootstrap
│   ├── autoload.php
│   ├── paths.php
│   └── start.php
├── composer.json
├── composer.lock
├── index.html
├── public_html
│   ├── 400.shtml
│   ├── 401.shtml
│   ├── 403.shtml
│   ├── 404.shtml
│   ├── 413.shtml
│   ├── 500.shtml
│   ├── assets
│   ├── cp_errordocument.shtml
│   ├── error_log
│   ├── favicon.ico
│   ├── index.php
│   ├── info.php
│   ├── less
│   ├── packages
│   ├── robots.txt
│   └── upload

I have tried greping the entire directory for the original url and found it in the app/config/app.php under ´url´ but after changing that link with localhost, I still get redirected.

There is this .htacces file inside the public_html direcotry:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.tenispremium.ro/$1 [R,L]

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php70” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

What and how do I change the .htacces so that it runs the site locally?

0

There are 0 best solutions below