CodeIgniter2.0 It's out there 20 It's been a long time ~ That's what I use all the time php frame (CI). It's been studied jquery, It's a good idea CI It's forgotten , ha-ha ~~ There are not many things in the company today , So I began to get familiar with CI2.0 Some new features of ~~ I'll just go over it again CI Some characteristics of . I don't see much in the morning , There's a little bit of knowledge ,CI By default index.php The file will be included in your URL Medium , If you want to go from url Delete the default index.php, Then we need to use Apache Powerful Rewrite The function of .

CI Of Official documents The solution given in is like this :

establish .htaccess Put the file in the root directory of the website , The contents of the document are as follows :

RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

ha-ha ~~ Because I am right Appache I haven't studied these rules very deeply , So I found something about it on the Internet appache Of RewriteCond A little bit of information about , I think it's well written and detailed , Now share with you :

———————————- Just a little bit ———————————————————
Apache in RewriteCond Sentence has always been a difficulty for me , Many times trying to figure it out , There's no structure , This time I finally know what it means .
RewriteCond Just like in our program if The sentence is the same , Represents execution if certain or several conditions are met RewriteCond Immediately below RewriteRule sentence , This is it. RewriteCond The most primitive 、 Basic function , For ease of understanding , Let's look at some examples .

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5.0.*
RewriteRule index.php index.m.php RewriteCond %{HTTP_USER_AGENT} ^Lynx.*
RewriteRule index.php index.L.php RewriteRule index.php index.b.php

On The function of face sentence is when you use FF Browser access index.php This file , It will automatically give you access index.m.php This file , When you're accessing it from some mobile terminal When , Will let you right index.php The access to this file actually accesses index.L.php Go to , If you are using another browser access , Will make you jump index.b.php. Let's talk about visualization , The above statement is the same as the following statement in the program ( In accordance with the PHP Statements, for example ):

if($_SERVER['HTTP_USER_AGENT'] == 'Mozilla/5.0')
{
// Jump to the index.m.php The interview of
}
else if($_SERVER['HTTP_USER_AGENT'] == 'Lynx')
{
// Jump to the index.L.php The interview of
}
else
// Jump to the index.b.php The interview of

Another example 2:

RewriteCond %{HTTP_REFERER} (www.test.cn)
RewriteRule (.*)$ test.php

The above statement is used if the host address of the previous page you visited is www.test.cn, No matter which page you are currently visiting , All jump to right test.php The interview of .

Let's look at example 3 :

RewriteCond %{REMOTE_HOST} ^host1.* [OR]
RewriteCond %{REMOTE_HOST} ^host2.* [OR]
RewriteCond %{REMOTE_HOST} ^host3.*
RewriteRule (.*)$ test.php

The above statement is used if your address is host1 or host2 or host3 When , I jump to the right test.php. You can see it here ,RewriteCond The default between statements is AND, If you want to OR, I want to write it explicitly .

Here are some useful rewriting rules from my collection :

RewriteCond %{REQUEST_FILENAME} !-f // If the file exists , Just access the file directly , I'm not going to do the following RewriteRule.( Overrides are not performed on a file or if the file does not exist )
RewriteCond %{REQUEST_FILENAME} !-d //# Direct access to the directory does not occur if the directory exists RewriteRule
RewriteCond %{REQUEST_URI} !^.*(.css|.js|.gif|.png|.jpg|.jpeg)$ //# If it's a file with these suffixes , Just access the file directly , Don't make Rewrite

———————————- Just a little bit ———————————————————

Apache in RewriteCond Introduction to rule parameters ( turn ) More articles about

  1. Apache in RewriteCond Introduction to rule parameters

    Apache in RewriteCond Sentence has always been a difficulty for me , Many times trying to figure it out , There's no structure , This time I finally know what it means .RewriteCond Just like in our program if The sentence is the same , It means that if it conforms to a certain ...

  2. Apache in RewriteCond Introduction to rule parameters

    RewriteCond The directive defines the conditions for the rule to take effect , In one RewriteRule An instruction can be preceded by one or more RewriteCond Instructions . The rewrite rule after the condition is only in the current URI And Pattern Match and satisfy the conditions here ...

  3. Apache in RewriteCond Introduction to rule parameters turn

    Abstract : RewriteCond The directive defines the conditions for the rule to take effect , In one RewriteRule An instruction can be preceded by one or more RewriteCond Instructions . The rewrite rule after the condition is only in the current URI And Pattern Match and satisfy this ...

  4. Apache in RewriteRule Introduction to rule parameters

    Apache in RewriteRule Introduction to rule parameters Abstract : Apache modular mod_rewrite Provides a rewriting engine based on regular expression analyzer to rewrite in real time URL request . It supports that each complete rule can have an unlimited number of ...

  5. elementary analysis Apache in RewriteCond Detailed introduction of rule parameters

    RewriteCond Just like in our program if The sentence is the same , Represents execution if certain or several conditions are met RewriteCond Immediately below RewriteRule sentence , This is it. RewriteCond The most primitive . Basic function , For the sake of prescription ...

  6. htaccess In file RewriteRule Introduction to rule parameters

    .htaccess file <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d Rew ...

  7. apache in RewriteCond Introduce

    One .Yii2 URL beautify modify Apache Before configuration file , You need to be in httpd.conf Search for  rewrite , Check it out. LoadModule rewrite_module modules/mod ...

  8. Apache Of rewrite The rules are detailed

    Apache Of rewrite The rules are detailed Release date :2008-09-02 16:16  source :  author :  Click on :7044 rewrite sign R[=code](force redirect) Forced external reset ...

  9. Django in HttpRequest Introduction to common parameters

    HttpRequest Object common parameters introduction , As well as the different request methods of the front end (http Method /Content-Type type ) The corresponding parameter acquisition method . One .HttpRequest object django The detailed parameters of the request object and the implementer ...

Random recommendation

  1. Java Learning notes ( 5、 ... and )——google java Programming style guide ( in )

    [ In front of the word ] I'm going to work in the next year , Plan to do a lot of things , But there will always be interruptions like this and that , I don't know if I'm demanding too much or I don't have enough sense of struggle ? Come on . Learn technology , Study English well , Study hard and do something you like , Take advantage of yourself ...

  2. PHP in strtotime Function usage sharing

    stay PHP One of them is called strtotime Function of .strtotime Realization function : Get the timestamp of a date , Or get a timestamp of a time .strtotime Resolve the date time description of any English text to Unix Time stamp [ Set the system time ...

  3. Chapter 43 、 utilize NSProxy solve NSTimer Memory leak problem

    Problem description : use NSTimer To perform the tasks set at regular intervals , For example, the most common ad carousel . If we were timerWithTimeInterval:1 target:self It is specified in target For the current controller ...

  4. flappy pig Small game source code analysis (2)—— The anatomy of the option

    Continue to analyze today flappy bird Source code . Review the directory structure of the source code . In the first part of this series, we analyzed game.js file , That's the architecture of the whole program . Let's take a look at this one option.js file , The content of this file is very simple , Lord ...

  5. node.js Its route , middleware ,ge Request and post Requested parameters

    One . route 1. What is routing The server needs to be based on different URL Or request to perform a different operation , We can achieve this step by way of origin 2. The way to implement routing 2.1.get When requesting access to the web address , What to do 1 app.get(" ...

  6. CSharp Programmer Science Android Development ---1. First time to know AndriodIDE, Master the use of tools

    Recently, the company organized project team members to develop a Android Project Demo, No one had before Andoid Development experience in , It's all about development C# Of . Although the project requirements are not very high , But for those who don't have the experience , The first step is the most difficult . Project history ...

  7. utilize jstack Exception code found

    1.top Find out what time it takes pid A process or ps -ef |grep xxx find pid 2.ps p 3036 -L -o pcpu,pid,tid,time,tname,cmd  3036 by pid 3.prin ...

  8. centos install redis

    1. Download address :$ wget http://download.redis.io/releases/redis-3.0.3.tar.gz 2. decompression $ tar -zvxf redis-3.0.3.ta ...

  9. EXADATA Intelligent scanning

    summary : Query specific requirements : Smart scan can only be used for full table or index scans . Smart scan can only be used for direct path reading : Direct path reads are automatically used for parallel queries . Direct path reading can be used for serial queries . By default, they are not used for serial scanning of small tables . Use ...

  10. C Language -- Linked list basic template

    1. Building structures struct ST { int num;/// Student number int score;/// achievement struct ST*next; };/// Structure 2. The creation of an empty list struct ST creatN ...