Welcome Guest, Not a member yet? Register   Sign In
Yet another help request for .htaccess
#1

[eluser]ironlung[/eluser]
Hi I've put my index.php file in a sub-directory of root /public_html/ and direct everything there using the following

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/public_html
RewriteRule (.*) /public_html/$1

How would I get rid of the need for index.php in the url in this case?

Also a method of banning access to other sub-driectories of root that are not /public_html/ would be a bonus.


Many many many thanks in advance - I can't get my head round the damned thing at all Smile


regards
#2

[eluser]TheFuzzy0ne[/eluser]
I can see several things that may be causing your problem, but I'd like to instead ask that you please check out the htaccess file on the wiki. In most cases, it works straight out of the box - http://codeigniter.com/wiki/mod_rewrite/.
#3

[eluser]ironlung[/eluser]
Ok i'll give that a try will.

Many Thanks
#4

[eluser]ironlung[/eluser]
My old solution

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^/public_html
RewriteRule (.*) /public_html/$1


redirected everything fine to /public_html/ now when I use the mod rewrite its lost all the referenced files in my html ie. the css images etc

I changed the new solution like this to get it to work at all.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /


#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /public_html/index.php?/$1 [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
RewriteRule ^(.*)$ /public_html/index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>


I really don't understand the .htaccess stuff at all any help gratefully received Smile
#5

[eluser]TheFuzzy0ne[/eluser]
My point was that there shouldn't be a need to change anything. What was wrong with it before you made the changes? If you can tell us the specific problem you're getting, it's easier to find a solution, but I would find it much easier starting with an htaccess file I know to be working. Hope that makes sense.
#6

[eluser]ironlung[/eluser]
Hi and thanks for your hasty reply


This is the error I get with the vanilla htaccess file

Not Found

The requested URL /index.php was not found on this server.


The problem being that I want my index.php to be off the root just for tidyness in a directory called /public_html/ all the other stuff hangs off the in /assets/

to clarify system and application are also off of root
so I have root empty of files
and
/public_html
/system
/application

hanging off of it.
#7

[eluser]TheFuzzy0ne[/eluser]
Ah, OK. Sorry, I wasn't aware of your intended setup. Reading your first post makes sense to me now, but it didn't originally. OK, so what happens when you use your modified version of the htaccess from the wiki?

EDIT: I'm also quite intrigued by your structure. Ideally, the system and application directories should be outside of your Web root, and the only things inside it should be things such as script, css and image directories and the index.php file.
#8

[eluser]Dam1an[/eluser]
[quote author="TheFuzzy0ne" date="1242356953"]
EDIT: I'm also quite intrigued by your structure. Ideally, the system and application directories should be outside of your Web root, and the only things inside it should be things such as script, css and image directories and the index.php file.[/quote]
And the license.txt Tongue
#9

[eluser]TheFuzzy0ne[/eluser]
Holy poop on a stick. That one should have been at the top of the list.
#10

[eluser]ironlung[/eluser]
[quote author="TheFuzzy0ne" date="1242356953"]Ah, OK. Sorry, I wasn't aware of your intended setup. Reading your first post makes sense to me now, but it didn't originally. OK, so what happens when you use your modified version of the htaccess from the wiki?

EDIT: I'm also quite intrigued by your structure. Ideally, the system and application directories should be outside of your Web root, and the only things inside it should be things such as script, css and image directories and the index.php file.[/quote]


Ok kewl, thanks for your help again Smile

I read load of ideal setups and watched some vids when i first started this project and I gleamed maybe incorrectly that to split system from application and then to keep all the other stuff in 1 dir with the assets off of it etc was a good idea

So I decided on
/public-html/
/assets
/css
/js
/application
/system

With the idea that index.php would go in public_html and everything roots to there. If your saying this is a bad idea let me know a better setup with more security and I'll change -I'm easy Smile

With my modified setup, index.php loads and processes correctly but it can't find the assets etc as its not rooting to public_html if I go and change the links from assets/css/cdd.css to public-html/assets/css/cdd.css for example it works I just didn't want to have to change all the links if I could help it.


Kind Regards




Theme © iAndrew 2016 - Forum software by © MyBB