Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter - URL is not working properly
#1

[eluser]Unknown[/eluser]
Hi, I am trying to work out my URL's with a newly installed CodeIgniter (2.1.3)

In short, this is my problem:

http://www.hquarter.com/about
403 - You do not have permission for this request /about

http://www.hquarter.com/Sertus/index.php/about
Correct loaded page

location of codeigniter (my projekt) www/Sertus/index.php.
My .htaccess setup:
Meant to let only specified IP's in, remove index.php and remove /Sertus/
Lastly only the www/sertus/index.php should be the only accesible file along with CSS and harmless graphic content).
Do you see any errors in the following code for the .htaccess?

# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?hquarter.com$
RewriteCond %{REQUEST_URI} !^/www/Sertus/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /Sertus/$1
RewriteCond %{HTTP_HOST} ^(www.)?hquarter.com$
RewriteRule ^(/)?$ Sertus/index.php [L]
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^ip\.ip\.ip\.ip$
#when apache denies other IP
RewriteCond %{REQUEST_URI} !^/hquarter/maintenance\.php$
RewriteRule ^(.*)$ /hquarter/maintenance.php [L]

#CODEIGNITER
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /

### Canonicalize codeigniter URLs
RewriteRule ^(pages(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]

# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

# Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /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 ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>

# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php

</IfModule>

I really hope you can help me, i've been sitting on this all night and it drives me crazy.
Thanks in advance,

Secho
#2

[eluser]Aken[/eluser]
First, I'd always suggest starting as simple as possible -- your .htaccess has a ton of stuff in there, I can't tell what's necessary and what's not. Too many places for things to fail to point down a specific problem.

Second, things would be a lot easier for you if your CodeIgniter install was located in the root, not in a subfolder. Because it seems you're trying to route all your .com's URLs to a CI install located in a subfolder. That seems unnecessary and overly complicated. Do you have a specific reason for putting CI in a subdirectory?
#3

[eluser]Unknown[/eluser]
Thanks a lot for taking your time Aken.

You are definately true about the overcomplicated code. It was a mess - Ind I finally sorted it out.
My intention was to set up the .htaccess in the /www to handle everything. I've now split up like this:
1.
/www/ht.access <-- Only my IPs can log in while constructing the site /sets subdomainFolder / removes index.php
2.
/www/MyProject(CI)/ht.access <-- Handles CodeIgniter (Removes access to system and checking if files are valid)

From here, my routes are handling URL redirection from the front controller.

Is this by default safe from SQL injections and general attacks?

Note: The reason I want to keep it in a subfolder is because of the security. I can handle the users better that way, and easier move the project to another server - as it is independent.




Theme © iAndrew 2016 - Forum software by © MyBB