htaccess to remove index.php, with multiple domainsI want to disable the access of a directory but not the child directory with .htaccesshtaccess url re-styling image url to seo friendlyUnable to remove index.php in WAMP with Codeigniter URLhtaccess doesnt remove index.php if WWW is in the URLMultiple languages + Htaccesshtaccess stop auto redirecting to a unknown folderThere is /index.php? in the URL when I use .htaccess to redirect404 issue in two htaccess in root domain and subfolerNot working my .htaccess and config filesset domain to subdirectory and subdomain to root directory
What to do when my ideas aren't chosen, when I strongly disagree with the chosen solution?
Identify a stage play about a VR experience in which participants are encouraged to simulate performing horrific activities
What (else) happened July 1st 1858 in London?
Lifted its hind leg on or lifted its hind leg towards?
Hostile work environment after whistle-blowing on coworker and our boss. What do I do?
Bob has never been a M before
Is infinity mathematically observable?
Is it okay / does it make sense for another player to join a running game of Munchkin?
What does the "3am" section means in manpages?
How do ultrasonic sensors differentiate between transmitted and received signals?
Can a Gentile theist be saved?
Giant Toughroad SLR 2 for 200 miles in two days, will it make it?
Is the next prime number always the next number divisible by the current prime number, except for any numbers previously divisible by primes?
How do I repair my stair bannister?
Why is delta-v is the most useful quantity for planning space travel?
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
Is there any significance to the Valyrian Stone vault door of Qarth?
Why isn't KTEX's runway designation 10/28 instead of 9/27?
The most efficient algorithm to find all possible integer pairs which sum to a given integer
Can I Retrieve Email Addresses from BCC?
How to interpret the phrase "t’en a fait voir à toi"?
Is there an wasy way to program in Tikz something like the one in the image?
Are taller landing gear bad for aircraft, particulary large airliners?
What is the term when two people sing in harmony, but they aren't singing the same notes?
htaccess to remove index.php, with multiple domains
I want to disable the access of a directory but not the child directory with .htaccesshtaccess url re-styling image url to seo friendlyUnable to remove index.php in WAMP with Codeigniter URLhtaccess doesnt remove index.php if WWW is in the URLMultiple languages + Htaccesshtaccess stop auto redirecting to a unknown folderThere is /index.php? in the URL when I use .htaccess to redirect404 issue in two htaccess in root domain and subfolerNot working my .htaccess and config filesset domain to subdirectory and subdomain to root directory
This seems so basic, and there's a plethora of questions regarding .htaccess online, but after two days of research, I still can't make mine work the way I want.
What I want is:
Force https on all requests
Always use the "www" version of the url.
Work on multiple domains (but not redirect them all to a master domain). All my domains point to the same folder (so they'd use the same codebase), and in its root is the .htaccess file.
Remove the "index.php" part of the url, to make it human and SEO friendly.
This is what I have so far:
Start with the basic .htaccess code for CodeIgniter, as shown in the userguide:
RewriteEngine On
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)$ index.php/$1
Originally, the last line had the [L] flag, but I omitted it, so it will continue to the following rules.
(Am I correct in assuming that it takes the url output in the previous RewriteRule, and perform the following matches on it?)
# for non www urls, add www and force https:
RewriteCond %HTTP_HOST(.*) !^www. [NC]
RewriteRule ^(.*)$ https://www.%HTTP_HOST/$1 [R,L]
# for www urls, just force https:
RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]
The above code is achieving tasks 1-3 of my list above, but the index.php is still showing in the address bar.
How do I remove it?
.htaccess codeigniter codeigniter-htaccess
add a comment |
This seems so basic, and there's a plethora of questions regarding .htaccess online, but after two days of research, I still can't make mine work the way I want.
What I want is:
Force https on all requests
Always use the "www" version of the url.
Work on multiple domains (but not redirect them all to a master domain). All my domains point to the same folder (so they'd use the same codebase), and in its root is the .htaccess file.
Remove the "index.php" part of the url, to make it human and SEO friendly.
This is what I have so far:
Start with the basic .htaccess code for CodeIgniter, as shown in the userguide:
RewriteEngine On
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)$ index.php/$1
Originally, the last line had the [L] flag, but I omitted it, so it will continue to the following rules.
(Am I correct in assuming that it takes the url output in the previous RewriteRule, and perform the following matches on it?)
# for non www urls, add www and force https:
RewriteCond %HTTP_HOST(.*) !^www. [NC]
RewriteRule ^(.*)$ https://www.%HTTP_HOST/$1 [R,L]
# for www urls, just force https:
RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]
The above code is achieving tasks 1-3 of my list above, but the index.php is still showing in the address bar.
How do I remove it?
.htaccess codeigniter codeigniter-htaccess
add a comment |
This seems so basic, and there's a plethora of questions regarding .htaccess online, but after two days of research, I still can't make mine work the way I want.
What I want is:
Force https on all requests
Always use the "www" version of the url.
Work on multiple domains (but not redirect them all to a master domain). All my domains point to the same folder (so they'd use the same codebase), and in its root is the .htaccess file.
Remove the "index.php" part of the url, to make it human and SEO friendly.
This is what I have so far:
Start with the basic .htaccess code for CodeIgniter, as shown in the userguide:
RewriteEngine On
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)$ index.php/$1
Originally, the last line had the [L] flag, but I omitted it, so it will continue to the following rules.
(Am I correct in assuming that it takes the url output in the previous RewriteRule, and perform the following matches on it?)
# for non www urls, add www and force https:
RewriteCond %HTTP_HOST(.*) !^www. [NC]
RewriteRule ^(.*)$ https://www.%HTTP_HOST/$1 [R,L]
# for www urls, just force https:
RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]
The above code is achieving tasks 1-3 of my list above, but the index.php is still showing in the address bar.
How do I remove it?
.htaccess codeigniter codeigniter-htaccess
This seems so basic, and there's a plethora of questions regarding .htaccess online, but after two days of research, I still can't make mine work the way I want.
What I want is:
Force https on all requests
Always use the "www" version of the url.
Work on multiple domains (but not redirect them all to a master domain). All my domains point to the same folder (so they'd use the same codebase), and in its root is the .htaccess file.
Remove the "index.php" part of the url, to make it human and SEO friendly.
This is what I have so far:
Start with the basic .htaccess code for CodeIgniter, as shown in the userguide:
RewriteEngine On
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)$ index.php/$1
Originally, the last line had the [L] flag, but I omitted it, so it will continue to the following rules.
(Am I correct in assuming that it takes the url output in the previous RewriteRule, and perform the following matches on it?)
# for non www urls, add www and force https:
RewriteCond %HTTP_HOST(.*) !^www. [NC]
RewriteRule ^(.*)$ https://www.%HTTP_HOST/$1 [R,L]
# for www urls, just force https:
RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]
The above code is achieving tasks 1-3 of my list above, but the index.php is still showing in the address bar.
How do I remove it?
.htaccess codeigniter codeigniter-htaccess
.htaccess codeigniter codeigniter-htaccess
edited Mar 7 at 20:39
einav
asked Mar 7 at 9:57
einaveinav
395524
395524
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Well, I (partially) gave up on .htaccess, and solved my problem in a different way:
I'm now using CodeIgniter hook to deal with forcing https, and leave htaccess to deal only with forcing www and removing index.php
So I removed the last line (RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]), and added an ssl hook to my application, and all is working now.
The hook function, in case anyone is interested, is this:
function force_ssl()
if ($_SERVER['HTTP_HOST']!='localhost' && $_SERVER['HTTP_HOST']!='10.0.2.2')
$CI =& get_instance();
$CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 443) redirect($CI->uri->uri_string());
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55040849%2fhtaccess-to-remove-index-php-with-multiple-domains%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Well, I (partially) gave up on .htaccess, and solved my problem in a different way:
I'm now using CodeIgniter hook to deal with forcing https, and leave htaccess to deal only with forcing www and removing index.php
So I removed the last line (RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]), and added an ssl hook to my application, and all is working now.
The hook function, in case anyone is interested, is this:
function force_ssl()
if ($_SERVER['HTTP_HOST']!='localhost' && $_SERVER['HTTP_HOST']!='10.0.2.2')
$CI =& get_instance();
$CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 443) redirect($CI->uri->uri_string());
add a comment |
Well, I (partially) gave up on .htaccess, and solved my problem in a different way:
I'm now using CodeIgniter hook to deal with forcing https, and leave htaccess to deal only with forcing www and removing index.php
So I removed the last line (RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]), and added an ssl hook to my application, and all is working now.
The hook function, in case anyone is interested, is this:
function force_ssl()
if ($_SERVER['HTTP_HOST']!='localhost' && $_SERVER['HTTP_HOST']!='10.0.2.2')
$CI =& get_instance();
$CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 443) redirect($CI->uri->uri_string());
add a comment |
Well, I (partially) gave up on .htaccess, and solved my problem in a different way:
I'm now using CodeIgniter hook to deal with forcing https, and leave htaccess to deal only with forcing www and removing index.php
So I removed the last line (RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]), and added an ssl hook to my application, and all is working now.
The hook function, in case anyone is interested, is this:
function force_ssl()
if ($_SERVER['HTTP_HOST']!='localhost' && $_SERVER['HTTP_HOST']!='10.0.2.2')
$CI =& get_instance();
$CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 443) redirect($CI->uri->uri_string());
Well, I (partially) gave up on .htaccess, and solved my problem in a different way:
I'm now using CodeIgniter hook to deal with forcing https, and leave htaccess to deal only with forcing www and removing index.php
So I removed the last line (RewriteRule ^(.*)$ https://%HTTP_HOST/$1 [R,L]), and added an ssl hook to my application, and all is working now.
The hook function, in case anyone is interested, is this:
function force_ssl()
if ($_SERVER['HTTP_HOST']!='localhost' && $_SERVER['HTTP_HOST']!='10.0.2.2')
$CI =& get_instance();
$CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 443) redirect($CI->uri->uri_string());
answered Mar 7 at 23:59
einaveinav
395524
395524
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55040849%2fhtaccess-to-remove-index-php-with-multiple-domains%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown