We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Seo Urls
Seo Urls
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?
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?
Re: Seo Urls
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
remove/add need some
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
Re: Seo Urls
Thanks @Damian i will change my approach.
But how i can delete the .html or .php extension on my urls in NGINX ?
But how i can delete the .html or .php extension on my urls in NGINX ?
Re: Seo Urls
nginx can't use .php, proxy_pass from apache default for any nginx template
But .html include default because nginx faster use it
remove remove for site html and htm
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
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
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
But if your HTML files contain php code from this is necessary for correct operation
Re: Seo Urls
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 ?
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 ?
Re: Seo Urls
you need some rewrite rule, but best way use site engine module
for nginx you can modify any default template include him file
template:
than put file
than add rule in that file
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
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*;
}
Code: Select all
touche /home/<username>/conf/web/rewrite_nginx.you_domain.conf
Code: Select all
location ~<need url or reg_exp> {
proxy_pass http://real_url;
}
than in web ui change template for your site new_default