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
Objective
Recently applied for an SSL certificate to play, so the blog also enabled HTTPS (on the one hand because the spam comments too much, enable HTTPS should also be able to prevent some simple irrigation machine it?) )。
Then hear a friend to remind, Baidu search engine crawler is not to catch HTTPS, this will bring included problems.
Begin
After some thinking, think through the nginx rules to solve this problem, then the Internet to search r
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 code:
1, if (-d $ 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 rewrite type;}Rule: can be a string or a regular to indicate the destination URL that you
So, I want to implement a url:example.com/test.php/a/b/c, the Web directory has a test.php file, want to receive/a/b/c as routing parameters to implement the routing function.
If you do not set the Rewite rule, it is possible to open example.com/test.php, but open example.com/test.php/a/b/c will report 404. And then I just want to rewrite the rules myself.
After trying a lot of times, I found
location /test.php {
This is my existing configuration.
Location/{index index.php;} location/request/{rewrite ^/request/(. +) $/request?model=$1 break;} Location ~ \.php {fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;fastcgi_param REQUEST_ METHOD $request _method;}
What I want to achieve now is that when accessing:/request/concact path, rewrite to/request/?model=contact
Then the post parameter is n
Let's say I'm using a pan-resolved domain name of *.domain.com
Now I want to judge when the domain name is not www.domain.com and satisfies the condition for ([\w]{2,5}). Domain.com's two-level domain name is redirected to www.domain.com/domain.php?domain= ([\w]{ 2,5}) of the rewrite rule.
The first thing I wrote was this:
Set $domain ", if ($hots ~* ([\w]{2,5}). \domain\.com) { set $domain $;} if ($domain!~" www ") {
1. Create a new. htaccess file in the directory where you need to use the. htaccess file
this. htaccess file General Discuz, DEDECMS and other systems have their own
#. htaccess Rewrite rule
Rewrite ^ (. *)/archiver/((Fid|tid)-[w-]+.html) $ $1/archiver/index.php?$2 last;
Rewrite ^ (. *)/forum-([0-9]+)-([0-9]+). html$ $1/forumdisplay.php?fid=$2page=$3 last;
will study the Header of the Web server. HTTP_ACCEPT_LANGUAGE is the language received by the server. it is generally the language of the server. As you can see on the website, firefox will send multiple language information when installing multiple language packs, but the first choice must be.
For example, if a Chinese user uses an English browser, the browser jumps to English. However, you can also provide language options on websites of different language versions so that they can jump over.
contains "zh", because the first two letters of the information sent from simplified Chinese or traditional Chinese must be "zh, the following is an introduction to both Chinese and English versions:
Location/{set $ lang zh_CN; if ($ http_accept_language ~ * ^ Zh-tw) {set $ lang zh_TW; rewrite ^/$/index_zh_TW.html redirect;} if ($ http_accept_language ~ * ^ En) {set $ lang en_US; rewrite ^/$/index_en_US
1. Add a slash at the end of the URLThis adds a rewrite rule to the virtual host:Rewrite ^ (. *[^/]) $ $1/permanent;For example:server {Listen 80;server_name bbs.ttlsa.com; Rewrite ^ (. *[^/]) $ $1/permanent;}2. Remove the slash at the end of the URLThis adds a rewrite rule to the virtual host:Rewrite ^/(. *)/$/$1 Permanent;For example:server {Listen 80;server_na
Are you worrying about your website being swept away all the time? Is my website helpless without an enterprise-level firewall? If you are using nginx, congratulations. The nginx configuration file is a script program that can help you filter all the submitted content you want to filter. I have summarized some anti-injection scanning rules for nginx, hope to be u
Because you want to rewrite an address from/MAG/XX/XXX/->/M/xxxBut the original/MAG/XX/more/should be retainedIn this case, you have to write a strange regular expression. I have tried a lot of writing methods and I have not succeeded.
The first thing to think about is:
Location ~ * ^/MAG/[^/] +/[^ (more)] + /{Rewrite ^/MAG/[^/] +/(. *)/M/$1 permanent;}
[] Is not effective in writing. It matches a single
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.