Apache is the first layer of your website security. With Apache cinfiguration, you can do so many stuff like blocking specific request, limit request from specific server, block automatic crawlers, redirect to specific website or urls etc.
Below are few examples how you can redirect with Apache web server to improve better user experience. .htaccess file is the Apache configuration file where you can change settings. So put the below lines to change the apache settings.
Put the below line to .htaccess to redirect all routes to specific routes, e.g. https://laravelcode.com/
RewriteEngine on
Redirect 301 / https://laravelcode.com/
If you only want to redirect specific portion of sites, add below lines.
Redirect "/admin/" "https://www.laravelcode.com/admin/"
If you want to redirect only single URL to new page.
Redirect /path/to/old/url https://www.laravelcode.com/path/to/new/url
If you want to add .html extension in URL, here is it
RedirectMatch 301 ^/about https://www.laravelcode.com/about.html
If you want to redirect to specific pages in case of 404 error page,
ErrorDocument 404 https://laravelcode.com/page-not-found
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
If you forcefully want to add WWW in the URL.
RewriteCond %{HTTP_HOST} ^laravelcode.com
RewriteRule (.*) https://www.laravelcode.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.laravelcode.com
RewriteRule (.*) https://laravelcode.com/$1 [R=301,L]
I hope it will help you.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Get Last Inserted Record ID in PHP
Any table has id field which is AUTO_INC...Foreach loop through multidimensional array in PHP
Use the PHP nested loop You can simpl...Laravel 5.5 - Task Scheduling With Cron Job Example
Today, we are share in this tutorials &q...How to create custom checkboxes in HTML using CSS and jQuery
Use the CSS :checked Pseudo-class with j...How To Check and Increase Swap Space in Ubuntu
A computer has limited amount of physica...