1. Update APP_URL
in the .env
File:
You need to modify the APP_URL
variable in your .env
file to reflect the new domain.
Open the .env
file in the root of your Laravel project and update it like this:
env
APP_URL=https://your-new-domain.com
APP_URL
contains the full new domain, including the protocol (http or https).
2. Clear Laravel Cache:
After updating the.env
file, it’s important to clear the cache so that Laravel recognizes the changes. Run the following commands in your terminal or command line:
bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
bash
php artisan optimize:clear
3. Restart the Web Server:
If you’re using a web server like Nginx or Apache, you may need to restart the server for the changes to take effect. You can do this with:- Nginx:
bash
sudo service nginx restart
- Apache:
bash
sudo service apache2 restart
4. Update Links in the Database (If Applicable):
If you store URLs in the database (e.g., image links or other direct URLs), you will need to update those as well. You can do this via SQL directly or through Laravel Tinker. Example using SQL:sql
UPDATE your_table SET link = REPLACE(link, 'old-domain.com', 'new-domain.com');