Welcome! Log In Create A New Profile

Advanced

help with nginx conf & rewrites - former apache user

Posted by andrewjs18 
help with nginx conf & rewrites - former apache user
January 11, 2016 03:41PM
Hi folks,

I'm a newbie to nginx - been using apache for the past 3-4 years when I do sys admin work for a few sites I run in my spare time. I'm having trouble with either my vhost conf or my rewrites...I'm not sure which. I'm leaning towards the conf being the problem as some other stuff I'm trying to do is causing a similar problem.

What's happening is that some URLs on my site are adding a 2nd slash after .com, i.e., http://mysite.com//some-blog...

I'm also having this problem when I'm trying to redirect my domain from www to non-www.

Here's the totality of my vhost nginx conf:
[code]
#server {
#server_name www.mysite.com;
#return 301 $scheme://mysite.com$request_uri;
#}

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /sites/public_html;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name mysite.com www.mysite.com;

# Logs
access_log /sites/logs/access.log;
error_log /sites/logs/error.log info;

location /inc {
deny all;
return 403;
}

location / {

autoindex on;

#Mybb Rewrites
rewrite ^/([^&]*)&(.*)$ http://mysite.com/$1?$2 permanent;

# Google SEO Sitemap:
rewrite ^/((?i)sitemap-([^./]+)\.xml)$ /misc.php?google_seo_sitemap=$2;

# Google SEO URL Forums:
rewrite ^/((?i)forum-([^./]+))$ /forumdisplay.php?google_seo_forum=$2;

# Google SEO URL Threads:
rewrite ^/((?i)thread-([^./]+))$ /showthread.php?google_seo_thread=$2;

# Google SEO URL Announcements:
rewrite ^/((?i)announcement-([^./]+))$ /announcements.php?google_seo_announcement=$2;

# Google SEO URL Users:
rewrite ^/((?i)user-([^./]+))$ /member.php?action=profile&google_seo_user=$2;

# Google SEO URL Calendars:
rewrite ^/((?i)calendar-([^./]+))$ /calendar.php?google_seo_calendar=$2;

# Google SEO URL Events:
rewrite ^/((?i)event-([^./]+))$ /calendar.php?action=event&google_seo_event=$2;

try_files $uri $uri/ =404;

}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

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

I commented out the top few lines as it keeps adding // after .com. Once I figure out what's causing the extra slashes to be added, I'll adjust the 2nd server_name bit to remove www.mysite.com from it.

any help is greatly appreciated!!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 106
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready