Yii Framework Forum: Zmiana adresów url (zapłata za pomoc) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Zmiana adresów url (zapłata za pomoc) Rate Topic: -----

#1 User is offline   Kacykos 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 12-March 18

Posted 12 March 2018 - 12:57 PM

Witam szukam kogoś kto pokaże mi jak zmienić adresy url w pewnym skrypcie strony, przykład mojadomena.pl/acccount/login na mojedomena.pl/zaloguj
0

#2 User is offline   pceuropa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 96
  • Joined: 28-October 14
  • Location:Bruxelles, Belgium

Posted 19 March 2018 - 11:34 AM

Wystarczy skonfigurować moduł urlManager w pliku konfiguracyjnym aplikacji Yii2. W przypadku basic jest to plik /config/web.php

                  'urlManager' => [
                      'baseUrl' => '',
                      'enablePrettyUrl' => true,
                      'showScriptName' => false,
                      'normalizer' => [
                          'class' => 'yii\web\UrlNormalizer',
                          'action' => 302
                      ],
                      'rules' => [
                          '/' => 'site/index',
                          'zaloguj' => 'site/login',
                      ],

                  ],



Jeżeli serwerem jest Nginx to plik konfiguracyjny vhostów powinnien wyglądać mniej więcej tak:

server {  
	server_name example.dev;
	root /path/to/folder;

	index index.php;

	location / {
		try_files $uri $uri/ /index.php?$args;
	}

	location ~ \.php$ {
		try_files $uri =404;
		include fastcgi.conf;
	}
}


W moim przypadku plik /etc/nginc/fastcgi.conf jest:

fastcgi_index  index.php;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_intercept_errors on;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/9.0.1;
#fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;


W razie problemów jestem dostępny pod rafal|malpa|pceuropa.net lub 514 777 757 chętnie pomogę.
My Bitcoin | BOINC Science Project: Universe@Home & Radioactive@home
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users