CodeIgniter Forums
Weird problem that has me baffled. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Weird problem that has me baffled. (/showthread.php?tid=68417)



Weird problem that has me baffled. - John_Betong - 07-08-2017

The site is running the latest CI version 3.15 and using LetsEncrypt SSL. 

Pretty urls are setup and whenever I browse to "/css-is-awesome" the following page appears:
Code:
Not Found
 The requested URL  /css-is-awesome  was not found on this server.
 Apache/2.4.18 (Ubuntu) Server at www.MYSITE.com Port 443


I renamed the table record to "/why-is-css-is-awesome" and browsed to "/why-css-is-awesome" and it works OK.

I added this extra Redirect line in .htaccess
Code:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R=301,L]
Redirect 302 /css-is-awesome   /why-css-is-awesome

Browsed to "/css-is-awesome" and the "/why-css-is-awesome" page loads OK?

I have disabled and cleared the browser cache and also tried numerous other browsers withoutt success!

Where should I start looking to clear this error?


RE: Weird problem that has me baffled. - skunkbad - 07-08-2017

Do you actually have a route for /css-is-awesome ?

I would suspect something else in the .htaccess file causing a conflict. To test, temporarily remove everything you can from .htaccess and try again.

I do the HTTPS redirect a little different:


Code:
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]

RewriteRule ^(system|application|cgi-bin) - [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]



RE: Weird problem that has me baffled. - Diederik - 07-08-2017

You should have a look at the apache logfiles. There you will find the real path to the file that was not found. This could give you a hint if it is different then what you might expect.

On a ubuntu server I once looked for a few hours before I found out why some javascript files where not loading. On Ununtu some package (common-js) is installed on a default lamp stack. That package placed a global alias for /javascript/ for every virtual host. Man what was I pissed when I finaly found the reason why my own javascript files where not found...

Perhaps you are running into something similar!


RE: Weird problem that has me baffled. - InsiteFX - 07-08-2017

Maybe it thinks the /css is your css folder...


RE: Weird problem that has me baffled. - John_Betong - 07-08-2017

Hi @skunkbad,

Many thanks for your reply.

>>> Do you actually have a route for /css-is-awesome ?
I have no specific route set for "/css-is-awesome".
I do set numerous specific routes and if they all fail then fall-through to a quite complicated search class.

>>> I would suspect something else in the .htaccess file causing a conflict. 
>>> To test, temporarily remove everything you can from .htaccess and try again.
See later reply to @InsteFX which solved the problem.

>>> I do the HTTPS redirect a little different:
The supplied .htaccess failed and limited free time prevented me from tracing the errors.

This is the current .htaccess file which is likely to change.

 
Code:
# ALREADY GLOBALLY SET FOR ALL SITES
 # Options +FollowSymLinks
   RewriteEngine on

 # PROBLEM: - DOES NOT REDIRECT FOR NON www
   RewriteCond %{SERVER_PORT} 80
   RewriteRule ^(.*)$ https://www.johns-jokes.com/$1 [R=302,L]

 # WORKS OK and CI sets correct page canonical meta tag
   RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
   RewriteCond %{REQUEST_FILENAME} !-f          
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php/$1 [L,QSA]

 ErrorDocument 404 /index.php



RE: Weird problem that has me baffled. - John_Betong - 07-08-2017

(07-08-2017, 12:44 PM)Hi Diederik Many thanks for your reply. Wrote: >>> You should have a look at the apache logfiles. 
>>> There you will find the real path to the file that was not found. 
>> This could give you a hint if it is different then what you might expect.

I checked Apache2 access and error logs and was unable to find a solution. 

CodeIgniter did not report any errors.



RE: Weird problem that has me baffled. - John_Betong - 07-08-2017

>>> Maybe it thinks the /css is your css folder...
YES!!! 

I amended the following .htaccess ReWriteCond and it worked first time.

Code:
RewriteCond $1 !^(index\.php|images|css|robots\.txt|favicon\.ico|sitemap\.xml|Sitemap-static\.xml)
It's obvious once the solution is provided Smile Note to self not to copy and paste scripts that I do not fully understand.

Many, many thanks once again for your insightful suggestion Smile

[off topic]
I have had spasmodic server problems for about a month and eventually Apache2 showed the following warning:
Code:
System information disabled due to load higher than 1.0


The problem was resolved by a server reboot.

Meanwhile I searched and tried a tremendous amount of suggestions, none successful. After the reboot both Google and Bing Webmasters Tools started to recognise the server. Also all WebPage Test Sites started to work.

It was GWT that reported this particular error but not the solution Sad

[/off topic]