: This article mainly introduces thinkphp's rewrite configuration in nginx. if you are interested in the PHP Tutorial, refer to it.
If (! -E $ request_filename) {# address as the rewrite parameter to index. php. # Rewrite ^/(. *) $/index. php/$1; # if it is a subdirectory, use the following sentence and change subdir
Find a simple pseudo-static Nginx Rewrite such as www. a. coma. php? The number following id2id is variable nbsp; I need to rewrite it to nbsp; s. a. coma. php? Id2 access www. a. coma. php? Id2 is reading s. a. coma. php? Id2 is not a redirection. I want to find a simple pseudo-static Nginx
Requirement: Access http://192.168.1.222:8099/ksdkfd/callback where KSDKFD is any characterJump to http://192.168.1.222:8099/api/paycb/ksdkfdLocation ~* ^/.+/callback$ {Index index.html index.htm;Rewrite "^/(. +)/callback" "/api/paycb/$1" permanent;}The difference between break and lastLocation/break {rewrite/break/(. *)/test/$1 break;echo Break page;}Location/last {rew
: This article mainly introduces ThinkPHP32 to configure the URL mode as REWRITE mode in Nginx. if you are interested in the PHP Tutorial, refer to it. In apache, you only need to enable rewrite and add the rewrite configuration file in the website root directory.
In nginx,
The problem is this:
I configured the route in the Symfony2, the prefixes are respectively:
/admin/api/wap...
such as
Now I want to access these three corresponding routes by accessing the three self-domains, respectively
admin.domain.com => /admin/*api.domain.com => /api/*wap.domain.com => /wap/*
At present under the Nginx configuration, but it does not work, want to see you have any ideas and methods of experience, pointing out, is now trapped.
ser
If your thinkphp is installed in a level two directory, the Nginx pseudo-static method is set as follows, where SubDir is the directory name in which it resides.
location /subdir/ { if$request_filename){ rewrite ^/subdir/(.*)$ /subdir/index.php?s=$1 last; }}
If your THINKCMF is installed in a level two directory, the Nginx pseud
I'm using the Nginx1.9.9,laravel 5.1.11 version.
Project many people will feel, localhost under a pile of folders a pile of items, each time a new project is accustomed to directly under the site root directory, after all, in the local development debugging, how convenient how to come.
So I have a lot of things in localhost, http://localhost/asd/, or http://localhost/caugoo/similar to many, but now a lot of PHP framework to a route, configure a URL rewrite
I want to implement user requests
x.com/api/dosomethingForward to the root directory of the Web site
/api.phpProcessing.
Files that do not exist are given to
/index.phpProcessing, nginx configuration is as follows
if (!-e $request_filename) { rewrite (.*) /index.php$1 last; }location ^~ /api/{ rewrite (.*) /api.php$1 last;}location ~ (index|api|a
.
4, click the installation, follow the prompts to do the relevant configuration
5, configuration Well, again into the background, in the head will appear "My Site"-> "Management Network" Options menu, next you can manage or create a site, you can also open a theme or plug-ins for other sites to use.
6, if you want to bind other domain names to the site, you can install the WordPress MU domain Mapping plug-ins.
Nginx Multi-site
way of thinking: Nginx jump two times.You click to open the direct access is the dynamic URL, but made 301 jump to the back of this non-existent static page above, and here there is a pseudo-static rule, the static page to jump to the real dynamic page, but with the last tag, the URL will not change, so the front desk sees a static URLThe idea has, the back is simple, in front add a rewrite redirect can.Of
time we agent to 8082 Port, that is Upload-service service
rewrite "^/api/(.*)$" /$1 break, Path rewriting:
"^/api/(.*)$": matches the regular expression of the path, using the grouping syntax, /api/ all future parts as 1 groups
/$1: The target path of the override, which is used to refer to the grouping that the preceding regular expression matches to (the group number starts at 1), which is /api/ all that follows. So the new p
Nginx rewrite and gzip functions, nginxrewritegzip
Rewrite Module name: ngx_http_rewrite_module is automatically compiled by default.
Command: rewrite regex replacement [flag]
Regex: a regular expression used to match the uri of a user request.
Replacement: result after Rewriting
Flag:
Last: After rewriting, stop
script_filename $document _root$real_script_name;
Fastcgi_param script_name $real _script_name;
Fastcgi_param path_info $path _info;
}
In this way, the Nginx server can support PathInfo. However, you also need to configure the rewrite rule if you want to support the thinkphp Url_mode set to 2 mode. Locate the Access_log statement, and add the following statement above it:
Copy Code code as
there is a regular expression location# Not used[Configuration D]}Location ~ * \. (Gif | jpg | jpeg) $ {# Match all requests ending with gif jpg jpeg. However, for requests starting with/images/, Configuration D is used.[Configuration E]}Request matching example/-> Configuration/Index.html-> configuration B/Documents/document.html-> configuration C/Images/1.gif-> configuration D/Documents/1.jpg-> configuration ENote that the above matching is irrelevant to the sequence defined in the configurat
Looking at the Yii documentation today, we found that the recommended Nginx configuration parameters are:
Location/{
# Redirect everything that isn ' t a real file to index.php
Try_files $uri $uri//index.php$is_args$args;
}
Location ~ \.php$ {
Include Fastcgi_params;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass Unix:/var/run/php5-fpm.sock;
Try_files $uri = 404;
}
My local us
Codeingoniter configuration Nginx is as follows:
if (!-e $request _filename) {Rewrite ^.*$/index.php last;}
All directory files that are not available after configuration are redirected to index.phpCSS JS images within the resource folder of the root directory are not accessible. Display 404How can I make the resource directory not be redirected???
Reply content:
Codeingoniter configuration
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.