adding www. from http:// in codeigniter tried code - codeigniter

I have a domain name: http://dulaboratories.com want to change the http:// to http://www
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site.info$
RewriteRule (.*) http://www/$1 [R=301,L]

Try:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^dulaboratories\.com [NC]
RewriteRule ^(.*)$ http://www.dulaboratories.com/$1 [L,R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Related

how to redirect from http to https and delete www with subdomain in laravel 7

I have a subdomain.
I want to redirect all links to one link. And enable https and delete www from.
For example:
I want redirect all this links:
https://www.blog.example.com
https://blog.example.com
http://www.blog.example.com
http://blog.example.com
to:
https://blog.example.com
This is my .htaccess file:
Header always set Strict-Transport-Security "max-age=86400; includeSubDomains;" env=HTTPS
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
This is not a laravel specific issue. You have to edit your .htaccess file. Add the following code to your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

Laravel .htaccess redirect all in one (1.public 2.https 3.www→non-www)

I have laravel application where .htaccess is redirecting to Laravel's /public folder.
Today I've added the SSL support, and I successfully updated .htaccess to also redirect http to https.
In addition to that I need it to re-write the www to non-www. There are plenty of examples how to do it individually. But I cannot find how to do it in conjunction with the first 2 requirements. Please help.
my current htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
# for HTTPS
RewriteCond %{HTTPS} !^on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
#/ end of HTTPS
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
I updated your existing .htaccess
RewriteCond %{HTTPS} !^on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteRule ^(.*)$ public/$1 [L]
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Start with www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

Put angular and laravel under the same root folder (.htaccess)

I have this folder structure
--laravel
----public
------index.php
------uploads
--------image.jpg
--angular
----dist
------index.html
I want 3 things
1) http(s)://www.domain.com/public/uploads/image.jpg goes to laravel->public->uploads->image.jpg
2) http(s)://www.domain.com/api/test goes to laravel->public->index.php
3) http(s)://www.domain.com/every_other_url goes to angular->dist
I have create this .htacces file
DirectoryIndex index.html index.htm default.htm index.php index.php3 index.phtml index.php5 index.shtml mwindex.phtml
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^api/(.*)$ laravel/public/$1 [L]
RewriteRule ^public/(.*)$ laravel/public/$1 [L]
RewriteCond %{REQUEST_URI} !^/angular/dist/
RewriteRule ^(.*)$ /angular/dist/$1
</IfModule>
First and second requirements works properly. Now I need to fix the 3rd
(I'm not using the HashLocationStrategy)
DirectoryIndex /angular/dist/index.html
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^api/(.*)$ laravel/public/$1 [L]
RewriteRule ^public/(.*)$ laravel/public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.(.*) /angular/dist/$1.$2 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /angular/dist/index.html [NC,L]
</IfModule>

Redirect to index Codeigniter

I'm having problem with redirecting.
How do i redirect localhost/volleyball to localhost/volleyball/index.php?
because it displays my directory i want it to point to index.php. Btw, i'm using Codeigniter2.2
here's my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /volleyball/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
i got the answer, i added:
DirectoryIndex index.php

modrewrite not redirecting using htaccess

When i type domain.ca/keyword.html it should render using domain.ca/keyword.php but it does not. This is all i have in my htaccess file.
Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [NC]
RewriteCond %{REQUEST_URI} !^/robots.txt$ [NC]
RewriteCond %{REQUEST_URI} robots\.txt [NC]
RewriteRule .* http://domain.ca/robots.txt [R=301,L]

Resources