: 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
This article mainly describes the Nginx support thinkphp URL Rewrite configuration example, this article directly gives the configuration example, the need for friends can refer to the following
Overview
Nginx server is now a fairly popular open source Web server, many production environments are also using
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
The final effect is as follows:In fact, it is very simple, first create a test.php file in the HTML directory, as follows:Then use VI to open him, write a test source code, the source code is as follows:Then save exit, go to/usr/local/nginx/conf to find nginx.conf configuration file, modify it.In the 46 line to add the rules can be modified, white to play regular expression just, "$" is the NGINX reserved v
Rewrite the configuration url in nginx! Hostnameinforindex. php? Qssqhostnamessq_index.html I want to rewrite the above url to the following format. thank you! ------ Solution ------------------ lt; IfModulemod_rewrite.c gt; configure
Rewrite the configuration url in nginx! Hostname/infor/index. php? Q = ssqhostname/ssq_index.html I want to rewrite the above url to the following format. thank you !, Lt; IfModulemod_rewrite.c gt; configure url rewriting in Rew
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
Allow Nginx to support thinkphp URL rewriting and PathInfo
Enable the thinkphp to operate correctly on Nginx.
Simply add the following information in the configuration file to allow Nginx to parse the thinkphp website correctly.
?
?
location/project/ { index index.php; if (!-e $request _filename)
Allow Nginx to support thinkphp URL rewriting and PathInfo
Enable the thinkphp to operate correctly on Nginx.
Simply add the following information in the configuration file to allow Nginx to parse the thinkphp website correctly.
?
?
location/project/ { index index.php; if (!-e $request _filename)
URL rewriting refers to the direction/jump to a rule by configuring the Conf file so that the URL of the site reaches a certain state, such as common pseudo static, 301 redirects, browser orientation, etc.
RewriteGrammarWritten in the server block of the configuration file, such as:
server {Rewrite rule oriented path rewrit
I am using nginx and I have already add the line Location/file/ { ^/file/([0-9]+)/([0-9]+)/([ ^/]*)/([0-9]+)/(. *) $/file. php? ID=$1server=$2hash=$3expire=$4 File=$5last; }In the conf file of the domain.But the videos does not play.I have a try copy the parameters from the link to something likehttp://www.mydomain.com/file.php?id=1server=0hash=796609733f08c4bb8b89expire= 1464380369file=mp4/1.mp4And I can see the mp4 file playing if I pu
Add the following in location in the configuration file:Code
If (-d $ request_filename ){Rewrite ^/(. *) ([^/]) $ http: // $ host/$1 $2/permanent;}
in this way, nginx will make a judgment. If a folder is requested, the/symbol will be automatically added at the end. If a file is requested, the original URL is not changed. The following explains the
Overview
The Nginx server is now a fairly popular Open-source Web server, and many production environments are using Nginx servers. Now do the project most of the time is using thinkphp, but nginx default does not support thinkphp PathInfo mode, need to make a certain configuration.
Nginx configuration file
# Th
As you know, thinkphp is a widely used PHP development framework, so you need to support URLs rewrite and pathinfo in Nginx.Add the following lines to our Nginx configuration file.Accompanying text section:Location ~. php{Fastcgi_pass 127.0.0.1:9000;Fastcgi_index index.php;Set $real _script_name $fastcgi _script_name;if ($fastcgi _script_name ~ "^ (. +?\.php) (/.+) $") {Set $real _script_name $;Set $path _i
Search on the Internet many methods do not work, research one day, found that the following configuration can be perfect support for ' Url_model ' => 2 of the situation
Copy Code code as follows:
location/project/{
Index index.php;
if (!-e $request _filename) {
Rewrite ^/project/(. *) $/project/index.php/$1 last;
Break
}
}
Location ~. +\.php ($|/) {
Set $script $uri;
Set $path _info "/";
if ($uri ~ "^ (. +\.php)
Development environment
CodeIgniter 2.14PHP 5.4.18Nginx 1.4.2
CodeIgniter Configuration
The config.php file that opens Codeignite is modified as follows:
$config [' uri_protocol '] = "path_info";
Nginx Configuration
Open the Nginx profile nginx.conf file and modify it as follows:
# I am using the virtual host configuration
server {
listen ;
server_name dev.example.com;
Rew
one: URL rewrite ecshop caseRewrite syntax rewrite the position pattern after the regular expression is directed goods-3.html---->goods.php?goods_id=3Goods-([\d]+) \.html---> goods.php?goods_id =$1 Location/Ecshop {Index index.Php;rewrite Goods-([\d]+) \.html$/ecshop/goods.php?id=$1;
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.