简体   繁体   中英

https redirect of subdirectory using htaccess does not work for inner url

I am trying to redirect subdirectory from http to https. I am using codeigniter as framework :

http(s)://www.abc.com/new/

Here is my htaccess looks like this

RewriteEngine On
RewriteBase /new/

RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/new
RewriteCond %{QUERY_STRING} !^/new
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_URI}  !(\.png|\.pdf|\.jpg|\.gif|\.jpeg|\.bmp|\.js|\.css|\.html|\.php|\.txt|\.ttf|\.svg|\.woff|\.woff2)$
RewriteCond %{REQUEST_URI}  !js_elements
RewriteRule ^(.*)$ index.php?/$1 [L]

Now when I access my site using

abc.com/new 

then it redirects to me to

http(s)://www.abc.com 

which is fine but when I directly hit any inner url like

abc.com/new/customer/customer_list

then it does not redirects me to http(s) Can anyone solve my issue ?

Current folder layout
-index.php
-/xyz
    -index.php

your requirement is to turn this url
http://example.com/xyz/?username=xyz
into this url
http://example.com/xyz1/xyz


-----
use this code inside /xyz/.htaccess:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /xyz/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?xyz=$1 [L,QSA]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM