Welcome Guest, Not a member yet? Register   Sign In
htaccess problem, rewrite to stats folder
#1

[eluser]Référencement Google[/eluser]
Hi,

I've get a problem, cannot find a solution since I am not very good with htaccess and regular expressions. I have a stats folder on www.mysite.com/awstats/ and the problem is that codeigniter "think" it is a controller. So here is my .htaccess actually:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    
    # If the file or directory exists, show it
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]

    RewriteRule ^awstats$ /awstats/  [L]
    
    # Blank queries get sent to the index
    RewriteRule ^$ index.php [L]
    
    # All other queries get sent to the index as index.php/whatever
    # RewriteRule ^(.*)$ index.php/$1 [L]
    
    RewriteCond $1 !^(index\.php|images|robots\.txt|js|css|user_guide)
    RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>

Any help please?
#2

[eluser]Crafter[/eluser]
Your rewrite rule for the awstats is not neccessary because of the two lines above that rule.
#3

[eluser]Référencement Google[/eluser]
Yes, but it isn't working, this is why I am posting, trying to get some help to make that work while I am typing www.mysite.com/awstats I need that the stats folder is displayed, and this stats tools is not part of CI.
#4

[eluser]Crafter[/eluser]
So I take it your site is organised something like this

.htaccess ~~ your apache config override
index.php ~~ CI index file
=> system ~~ CI system dir
=> awstats ~~ non-CI dir
=> images ~~ example dir

Then just the RewriteCond should be sufficient.

What happens if you type:
- www.mysite.com/awstats
- www.mysite.com/somevalidontroller
- www.mysite.com/junkcontroller
#5

[eluser]Référencement Google[/eluser]
Yes it is exactly organized how you said.
Now typing this:

- www.mysite.com/awstats ===> CI 404 error
- www.mysite.com/somevalidontroller ===> OK
- www.mysite.com/junkcontroller ===> CI 404 error
#6

[eluser]Crafter[/eluser]
OK. I was trying to detriine if your htaccess was bwing processed at all.
www.mysite.com/somevalidontroller ===> OK
tells me it is.

I've tried this, with and without the awststats RewriteCond line, and it works. I can't think of what else may be preventing this form working.

BTW, perhaps state your OS. I know there has been some problems on XP where solutions have been tendered.

Alternatively, you could try using the apache alias tag
Alias /awstats "/var/www/default/awstats"
#7

[eluser]Référencement Google[/eluser]
Finally got it while trying and trying:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^awstats$ /awstats/  [R]
    
    # If the file or directory exists, show it
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]
    
    # Blank queries get sent to the index
    RewriteRule ^$ index.php [L]
    
    # All other queries get sent to the index as index.php/whatever
    RewriteRule ^(.*)$ index.php/$1 [L]
    
    RewriteCond $1 !^(index\.php|images|robots\.txt|js|css|user_guide)
    RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>

It is actually working like I want, but if you see something wrong in it, please say!

Thanks for the help Codecrafter
#8

[eluser]Référencement Google[/eluser]
No I was wrong, my post below does not work...
Also the server is a Linux server.

Trying this line Alias /awstats "/domains/site.com/public_html/awstats"
Give me an error 500

Any other idea?
#9

[eluser]Référencement Google[/eluser]
Just remembered I had a My_router function that can make this problem:

Code:
class MY_Router extends CI_Router
{
    function _validate_segments($segments)
    {
        if (count($segments) == 1 and file_exists(APPPATH.'views/static/'.$segments[0].EXT))
        {
            array_unshift($segments, 'static_page', 'show');
        }
        return parent::_validate_segments($segments);
    }
}

The problem is that I am not understanding enough things to find and solve the problem.




Theme © iAndrew 2016 - Forum software by © MyBB