• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.htaccess question

#1
I have my codeigniter 3.0.6 project structure like


Code:
www >

www > codeigniter

www > codeigniter > application

www > codeigniter > public

www > codeigniter > public > index.php


Question 1: Where should I put my htaccess? In the public?


Question 2: Currently I have to type in http://localhost/codeigniter/public/ to get to the home page On my htaccess is there away to be able to have it point to this http://localhost/codeigniter/


PHP Code:
Options +FollowSymLinks
Options 
-Indexes
DirectoryIndex index
.php
RewriteEngine on
RewriteBase 
/codeigniter/public
RewriteCond $!^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ index.php/$[L,QSA
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

#2
Q1. Normally yes. If you are addressing /codeigniter/ then rules from the route .htaccess will apply, and can be modified or further rules applied by the .htaccess file in the /codeigniter/ folder. A CI remove index.php htaccess should be in the CI root folder, in your case /codeigniter/
Having said that it all depends what you are doing. You can apply rules in the route .htaccess for other subfolders too.

Q2. You can change the webroot for Xampp (assuming you are using that) in their config files. Here is a handy stack overflow answer about it: http://stackoverflow.com/questions/18902...-directory

Personally I would not do this, but just accept that in development locally you have the additional folder in URL's. If you set your base_url in the config this is just one setting to change when you upload it to a live site.

Hope that helps in some way,

Paul.
Reply

#3
(07-01-2016, 12:55 AM)PaulD Wrote: Q1. Normally yes. If you are addressing /codeigniter/ then rules from the route .htaccess will apply, and can be modified or further rules applied by the .htaccess file in the /codeigniter/ folder. A CI remove index.php htaccess should be in the CI root folder, in your case /codeigniter/
Having said that it all depends what you are doing. You can apply rules in the route .htaccess for other subfolders too.

Q2. You can change the webroot for Xampp (assuming you are using that) in their config files. Here is a handy stack overflow answer about it: http://stackoverflow.com/questions/18902...-directory

Personally I would not do this, but just accept that in development locally you have the additional folder in URL's. If you set your base_url in the config this is just one setting to change when you upload it to a live site.

Hope that helps in some way,

Paul.

Thank you I thought it could be done with htaccess. But I think v host easier.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

#4
Sorry, I did not mean it cannot be done. I believe a rewrite rule on the .htaccess in your webroot can be used to rewrite everything to your /codeigniter/ folder. Only that would stop everything in other folders working, and sort of defeats the point. You may as well archive all the others and put your current project in your current web root.
Reply

#5
(07-01-2016, 12:55 AM)PaulD Wrote: Q1. Normally yes. If you are addressing /codeigniter/ then rules from the route .htaccess will apply, and can be modified or further rules applied by the .htaccess file in the /codeigniter/ folder. A CI remove index.php htaccess should be in the CI root folder, in your case /codeigniter/
Having said that it all depends what you are doing. You can apply rules in the route .htaccess for other subfolders too.

Q2. You can change the webroot for Xampp (assuming you are using that) in their config files. Here is a handy stack overflow answer about it: http://stackoverflow.com/questions/18902...-directory

Personally I would not do this, but just accept that in development locally you have the additional folder in URL's. If you set your base_url in the config this is just one setting to change when you upload it to a live site.

Hope that helps in some way,

Paul.

I found out how now

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^localhost/github/projects$ [NC,OR]
RewriteCond %{REQUEST_URI} !github/projects/public/
RewriteRule (.*) /github/projects/public/$1 [L]
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.