Welcome! Log In Create A New Profile

Advanced

Joomla search and nginx not working together

Posted by artem_v 
Joomla search and nginx not working together
July 30, 2013 12:28AM
Hey guys,

Hoping somebody can help me out with a problem that has me scratching my head for two days. I've re-create my apache website on a different server using nginx+php-fpm+mysql. It is a joomla 1.5.26 website. I have almost eveything working and the only thing left is the search functionality.

Lets say that my website is called food.com and I am on my homepage. If i type in the word "food" into the joomla search, my address bar changes to http://www.food.com/search.html?ordering=&searchphrase=all&searchword=food. No problem, the search works great from my homepage.

Now let's say that I am reading an article at http://www.food.com/breads/goodbreads.html and I type in the word food into the joomla search. The address bar changes to http://www.food.com/breads/index.php and I get a "404 not found" error.

If I do the same thing on my apache website, the address bar always changes to http://www.food.com/search.html?ordering=&searchphrase=all&searchword=food - no matter where i am in the site.

I know why I get the error - because nginx is requesting index.php from food.com/breads/. Obviously since its a CMS that directory does not exist. My problem is that I don't know why it requesting index.php. I don't know why it works from the homepage and not anywhere else. I'm pretty sure I need some url rewriting but I don't know where to start.

Any help is appreciated. Below is my nginx config.

server {
listen 80;
listen 443 ssl;
server_name xyz;
access_log /srv/www/www.xyz.com/logs/access.log;
error_log /srv/www/www.xyz.com/logs/error.log info;
root /srv/www/www.xyz.com/public_html;
index index.html search.html index.php;

location /administrator {
allow xxx.xxx.xxx.xxx;
deny all;
}

location / {
expires 1d;
# Enable joomla SEF URL's inside Nginx
try_files $uri $uri/ /index.php?$args;
}

# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|gz)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

}
Re: Joomla search and nginx not working together
July 30, 2013 09:31PM
Found a solution after many days of searching.

This is from a sh404sef forum.

"
Open this file: modules/mod_search/tmpl/default.php

and change:

<form action="index.php" method="post">

to:

<form action="<?php JRoute::_('index.php'); ?>" method="post">
"

This worked for me. Search is now working from all pages.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 163
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready