Skip to main content

Posts

Showing posts with the label htaccess

Laravel - Remove public from url

Solution - Laravel How to Remove /public from url Laravel is a most popular PHP framework and today we will solve most common issue with laravel  by removing /public from URL. This code is tested with Laravel 8(Latest) but it will work with Laravel 7, 5 version also. ISSUE When we move our site on live server and do not run our application through terminal and try to access website by entering url then we need to add /public to run it successfully, But its not good to keep /public in our website url that will not seo friendly and creates bad user experience. SOLUTION FOR LARAVEL REMOVE PUBLIC FROM URL Create a .htaccess file on your root directory and paste below code into .htaccess file and save it. try this code <IfModule mod_rewrite.c>     RewriteEngine On     RewriteRule ^(.*)$ public/$1 [L] </IfModule> or this one RewriteEngine On RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ ^$1 [N] RewriteCo...

Redirect www to non www url using htaccess

 Redirect www to non www url using htaccess   sSometimes we can access our website on both url like https://www.learncodetoday.com and https://learncodetoday.com , but its not good for SEO. So today we will learn how can we redirect a user from www to non-www url using htaccess. .htaccess file is a routing file that you can find on your project root folder and if its not exist there then you can create a .htaccess file there. Copy and paste below code into your .htaccess file for redirection RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteCond %{ENV:HTTPS} !on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] Now save file and try to open your website by using www url and it will auto redirect you on non-www url. Related Links How to remove www from url .htaccess to redirect an url Redirect my domain from www to non www domain url

Codeigniter - Remove index.php from url

Remove index.php from url in codeigniter By default codeigniter(CI) includes index.php in url but we can remove index.php from url easily by using htaccess.   To remove index.php from your codeigniter website url ,  create a .htaccess file in root directory and  paste the below code. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]     Now navigate to your website and you can access your  website without including index.php.