Monthly Archive: March 2019

laravel 5 only root route works/ index path works

Problem: Only ‘/’ route working --

Route::get('/', '[email protected]')->name('main.index');

Other routes return 404 using get and post method

Solution: Add below code to .htaccess in your project/ folder:

RewriteEngine On RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ RewriteRule ^(.*) - [E=BASE:%1] RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] RewriteCond %{REQUEST_FILENAME} -f RewriteRule .? - [L] RewriteRule .? %{ENV:BASE}/index.php [L]

How to Fix “Sorry, this file type is not permitted for security reasons” in WordPress

Fail to upload text file because of security reason

Problem: upload .txt, .csv or any other textbase file are all failed due to security reasons.

There are the default protection that WordPress setup for blogger, but for the website like us, we want to let user download text file for reference.

Solution: Add some code to let WordPress allow us to upload a text file in wp-config.php :

In file. Find the line /* That’s all, stop editing! Happy blogging. */ . Append below code before this Happy blogging line.


There is no existing directory at “…/storage/logs” and its not buildable: Permission denied

Problem: put the whole laravel project folder to another directory. e.g /var/www/html/laravel-project to /var/www/laravel-project . After the update of the Virtual Host File. The issue appears when accessing the website

This is because the server still use and contain the old path record in cache.

Solution: Clearing Configuration Cache, Application Cache and Route Cache.

php artisan route:clear
php artisan config:clear
php artisan cache:clear 

Block IP in phpmyadmin

problem: block IP in phpmyadmin (or allow some IP only)

Solution: edit /etc/phpmyadmin/apache.conf file (Ubuntu) to restrict access in PHPMyAdmin. In apache.conf file, find “/usr/share/phpmyadmin” in the file and change to below

<Directory /usr/share/phpmyadmin>
Order allow,deny
Allow from

save it and restart apache

sudo service apache2 restart

Restrict directory access in Apache by allow some ip only

problem: Want to protect specific web directory in a simple way in the testing server

Solution: build conf file to restrict access in Apache. Go to /etc/apache2/sites-available/ , create your conf file in this website, for example, Then add below code:

<Directory /var/www/html/itdocumentation/>
Order allow,deny
Allow from

Then enable this Virtual Host configuration file:


save it and restart apache

sudo service apache2 restart

Protect .env file in Laravel project in the testing server

Problem: In the testing server, the .env file is viewable (e.g ip/laravel_project/.env), people can view all the sensitive data like DB username and password.


The original solution is worked. All you need to do is change the .env file permission to 640. Then generate the Application Encryption Key again:

php artisan key:generate
php artisan config:cache

Solution: Change .env file permission while not affecting Laravel running

sudo chmod 640 .env
php artisan key:generate
php artisan config:cache


Put the hosting directory into /var/www but not /var/www/html, so that user can not access through http://IP/project_name/public/ but to domain name. You can also Restrict directory access in Apache by allow some ip only in order to protect .env file and other sensitive information.

“WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!” occurred when trying to connect server via SSH

Problem: Use SSH to connect the server as usual, then occur WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! message

The target server is re-format before, the authentication information has been changed. You have to delete the old authentication information in your computer first.



ssh-keygen -R (target server IP)


Go to the host key directory, in my case the directory is “C:\Users\paulck.ssh”. Find the known_hosts file, delete the line that contains target server IP.

(target server IP) ecdsa-sha2-nistp256 (RSA key)