CodeIgniter Forums
Check my .htaccess code please - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Check my .htaccess code please (/showthread.php?tid=65114)

Pages: 1 2


Check my .htaccess code please - flaboi - 04-30-2016

My goal is to add the www and enable HTTPS in all URLs, does this setup look fine?

Code:
RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]



RE: Check my .htaccess code please - skunkbad - 04-30-2016

Maybe something like this:

Code:
RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]



RE: Check my .htaccess code please - InsiteFX - 05-01-2016

You do not need this if your html file is setup correctly:

Code:
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)

Plus you may need to set it like this:

Code:
RewriteRule ^(.*)$ index.php?/$1 [L]



RE: Check my .htaccess code please - flaboi - 05-01-2016

(05-01-2016, 03:58 AM)InsiteFX Wrote: You do not need this if your html file is setup correctly:

Code:
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)

Plus you may need to set it like this:

Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

Hello,

Do you mind posting how the entire .htaccess should look if I want to add the www and enable SSL in URLs? I am not a web developer so it is hard for me to understand.

Thank you


RE: Check my .htaccess code please - InsiteFX - 05-01-2016

Force SSL https:


RE: Check my .htaccess code please - nkhan - 05-01-2016

Hi ,you can check this 
Code:
<IfModule mod_rewrite.c>

   Options +FollowSymLinks
   RewriteEngine on

   # Send request via index.php
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>



RE: Check my .htaccess code please - flaboi - 09-08-2016

Hi everyone,

I have added an SSL certificate and would like to have www in front of my domain, please can you check my current .htaccess code and let me know if I should make some changes:

Code:
RewriteEngine On

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]

Thanks!  Big Grin


RE: Check my .htaccess code please - InsiteFX - 09-09-2016

Code:
Not needed and can cause errors in an .htaccess file

RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)


HTML all you need is to add this to your head section on top.

<head>
<base href="<?php echo base_url(); ?>">
</head>



RE: Check my .htaccess code please - flaboi - 09-09-2016

I will remove that line from my current .htaccess file and add that to which file?


RE: Check my .htaccess code please - InsiteFX - 09-09-2016

You do not need it at all.