Welcome Guest, Not a member yet? Register   Sign In
Mod Rewrite works if site is in a sub directory but not in the root
#1

[eluser]Ty Bex[/eluser]
When i designed the website it was on my server http://www.domainname.com/DEV/ and the mod rewrite worked fine.
Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://example.com/
|
*/
$config['base_url']    = "http://www.domainname.com/DEV/";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "";

Since I moved it to the new website. http://www.plymouthparksoccer.org/ I had to load in the index_page variable for the site to work.
Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
|    http://example.com/
|
*/
$config['base_url']    = "http://www.plymouthparksoccer.org/";

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "index.php";


The Mod requite is being picked up because if I mess up the syntax is throws a server error.
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond $1 !^(index\.php|public|images|tmp|robots\.txt|css)
    RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

If I do not load the index_page variable with index.php. The links will all show correctly but it only displays the home page no matter what the address bar states.

The site right now is working with the index.php assigned but I would really love to know why it works if the site is in a sub directory and not if the site is in the root of the domain.
#2

[eluser]Ty Bex[/eluser]
Any Idea's..
#3

[eluser]Daniel Moore[/eluser]
For a complete walk-through of a good .htaccess, visit:
http://www.danielwmoore.com/remove_index...odeigniter

My first suggestion is to change:
Code:
RewriteRule ^(.*)$ index.php/$1 [L]

to:
Code:
RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]

The above referenced link should tell you why if you read through it all. This may very well fix the situation you are experiencing.

Another issue I would address is a simple house-cleaning issue.

Your lines:
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
and
Code:
RewriteCond $1 !^(index\.php|public|images|tmp|robots\.txt|css)
are redundant. Use one or the other, but not both. I recommend the first one. If you have directories that you do not want accessed, as you are indicating by "public|images|tmp|css" and you do not want these accessed directly, then simply place a .htaccess file in each directory you wish to deny access to, with a single line in the .htaccess file as follows:
Code:
deny from all
#4

[eluser]Ty Bex[/eluser]
SOLVED - Read next post for solution..
#5

[eluser]Ty Bex[/eluser]
[quote author="Daniel Moore" date="1241591372"]For a complete walk-through of a good .htaccess, visit:
http://www.danielwmoore.com/remove_index...odeigniter

My first suggestion is to change:
Code:
RewriteRule ^(.*)$ index.php/$1 [L]

to:
Code:
RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]

The above referenced link should tell you why if you read through it all. This may very well fix the situation you are experiencing.
[/quote]

It tuned out being the line with the ? after the index.php
Code:
RewriteRule ^(.*)$ index.php?/$1 [NC,L,QSA]

Thank you very much and excellent file with a great description. I have been lookiing for a good description file..




Theme © iAndrew 2016 - Forum software by © MyBB