Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Seo Urls

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
6 posts • Page 1 of 1
fremeni
Posts: 40
Joined: Sun Jun 15, 2014 11:14 pm

Seo Urls
  • Quote

Post by fremeni » Tue Jun 17, 2014 2:33 pm

Hi

I'm trying to makes urls much seo compliant.

I need to remove extensions like .html and .php.

I've tried a lot of thinks but nothing works.

For first i need to be sure that the file to be modified is xxx.xxx.xxx.xxx.conf on /etc/nginx/conf.d

Then i saw online that i must add something like this try_files $uri.html $uri $uri/ /index.html;

So my file will be

server {
listen xxx.xxx.xxx.xxx:80 default;
server_name _;
#access_log /var/log/nginx/xxx.xxx.xxx.xxx.log main;
location / {
proxy_pass http://xxx.xxx.xxx.xxx:8080;
try_files $uri.html $uri $uri/ /index.html;
}
}

I restart nginx but nothing happen.

Any idea?
Top

demian
Posts: 543
Joined: Thu May 16, 2013 5:19 am

Re: Seo Urls
  • Quote

Post by demian » Tue Jun 17, 2014 5:20 pm

wrong way!!!

don't modify config files any time/more

best way:
1. used web ui
2. modify or add template for nginx/apache

for exclude files from nginx use web-->your domain--> edit-->Nginx Extensions

Code: Select all

default:
jpg, jpeg, gif, png, ico, svg, css, zip, tgz, gz, rar, bz2, exe, pdf, doc, xls, ppt, txt, odt, ods, odp, odf, tar, bmp, rtf, js, mp3, avi, mpeg, flv, html, htm
remove/add need some
Top

fremeni
Posts: 40
Joined: Sun Jun 15, 2014 11:14 pm

Re: Seo Urls
  • Quote

Post by fremeni » Tue Jun 17, 2014 5:23 pm

Thanks @Damian i will change my approach.

But how i can delete the .html or .php extension on my urls in NGINX ?
Top

demian
Posts: 543
Joined: Thu May 16, 2013 5:19 am

Re: Seo Urls
  • Quote

Post by demian » Tue Jun 17, 2014 5:38 pm

nginx can't use .php, proxy_pass from apache default for any nginx template

But .html include default because nginx faster use it

Code: Select all

jpg, jpeg, gif, png, ico, svg, css, zip, tgz, gz, rar, bz2, exe, pdf, doc, xls, ppt, txt, odt, ods, odp, odf, tar, bmp, rtf, js, mp3, avi, mpeg, flv, html, htm
remove remove for site html and htm

Code: Select all

jpg, jpeg, gif, png, ico, svg, css, zip, tgz, gz, rar, bz2, exe, pdf, doc, xls, ppt, txt, odt, ods, odp, odf, tar, bmp, rtf, js, mp3, avi, mpeg, flv
and nginx drop it to back-end(apache), this will solw down
But if your HTML files contain php code from this is necessary for correct operation
Top

fremeni
Posts: 40
Joined: Sun Jun 15, 2014 11:14 pm

Re: Seo Urls
  • Quote

Post by fremeni » Tue Jun 17, 2014 5:47 pm

I perfeclty undertand now.

No, my html don't contain php but i would use the urls without extension (php and html) because is more seo compliant and is more elegant.

Maybe this will become available on VestaCp when the release will manage php files by Nginx + PHP-FPM ?
Top

demian
Posts: 543
Joined: Thu May 16, 2013 5:19 am

Re: Seo Urls
  • Quote

Post by demian » Tue Jun 17, 2014 6:16 pm

you need some rewrite rule, but best way use site engine module

for nginx you can modify any default template include him file

template:

Code: Select all

/usr/local/vesta/data/templates/web/nginx/new_default.tpl 
server {
    listen      %ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;
    error_log  /var/log/httpd/domains/%domain%.error.log error;

    include %home%/%user%/conf/web/rewrite_nginx.%domain%.conf*;

    location / {
        proxy_pass      http://%ip%:%web_port%;
        location ~* ^.+\.(%nginx_extentions%)$ {
            root           %docroot%;
            access_log     /var/log/httpd/domains/%domain%.log combined;
            access_log     /var/log/httpd/domains/%domain%.bytes bytes;
            expires        max;
            try_files      $uri @fallback;
        }
    }

     location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      http://%ip%:%web_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    disable_symlinks if_not_owner from=%docroot%;

    include %home%/%user%/conf/web/nginx.%domain%.conf*;
}
than put file

Code: Select all

touche /home/<username>/conf/web/rewrite_nginx.you_domain.conf
than add rule in that file

Code: Select all

location  ~<need url or reg_exp> {
proxy_pass      http://real_url;
}
NOTE: name_template.tpl and name_template.stpl is one template need modify/copy both file if you add some general directive

than in web ui change template for your site new_default
Top


Post Reply
  • Print view

6 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password