Using nginx rewrite to hide or clear urls?

Hey.

I try to use regexes and rewrite, but I'm new to it. I have a simple site, only one directory, all I want to do is rewrite domain.com/file.php?var=value to the .com domain, making sure that the user sees the domain com.com only in the address bar site (even if I start to make the site more complex).

Simply put, this is URL freezing, although if the site grows, I would rather make some kind of "clean URL", but I am still on the base php and I feel that I will need rtfm on http / 1.1

+3
source share
5 answers

nginx rewrite :

rewrite  ^([^.]*)$  /index.php

, "." index.php script. PHP , URL- , , php, :

#URL /people/jack_wilson
$url_vars = explode('/',$_SERVER['request_uri']); # array('','people','jack_wilson');
$page = $url_vars[1];
if($page == 'people'){
   $username = $url_vars[2];
   require('people.php'); #handle things from here.
}
+4

"" URL . URL- , .

, "" URL.

URL- .

, URL- "artsy", , , . - IMHO.

+3

, URL- , , : , IM, facebook, .

0

, php, ( ). , , - . , . domain.com/foo/bar, ; , nginx " URL-", , , , . domain.com/file.php?var1=value&var2=value , , .

( " " ), xhtml 1.1 Strict ( ). , , , .., , URL-:)

rtfm -, php, http/1.1 , ", , !" 4 .

:)

[ , , ... ]

0

PHP, Code Igniter, PHP .

http://codeigniter.com/

-1

Source: https://habr.com/ru/post/1703985/


All Articles