Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the rewriting process like using the Ci framework url

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail about the use of Ci framework url rewriting process is like, the content of the article is of high quality, so the editor to share to you as a reference, I hope you have a certain understanding of the relevant knowledge after reading this article.

Requirements, access address https://www.xx.net/de/twitter-video-download in the framework because methods in the framework cannot be used-to name

The method I thought of was twitter_video_download as the method name, but the / of the ci framework itself caused the rewrite to be unsuccessful

So the dynamic access mode of ci framework has been changed.

Ask, such as:

Http://www.myweb.com/index.php/weclome/index (welcome represents the controller, and index represents a method in the controller).

Http://www.myweb.com/index.php/admin/welcome/index (admin represents a subfile in the controller controler folder, welcome represents a controller in admin, and index represents a method in the welcome controller).

Second, used to use http://www.myweb.com/index.php?c=welcome&m=index&x=123131 such a common mode for access, for such a popular framework, I think CI will not only have a path to access URL form, this framework based on MVC pattern, there must be that kind of ordinary mode to access URL, this must be related to the configuration file, practice has proved that this is correct.

Method: open the application file application to find the configuration folder config, and then find the config.php file, as shown in the following figure

/ / before / / $config ['uri_protocol'] =' REQUEST_URI';// modified $config ['uri_protocol'] =' PATH_INFO';$config ['url_suffix'] =''; $config ['language'] =' english';$config ['charset'] =' UTF-8';$config ['enable_hooks'] = FALSE;$config [' subclass_prefix'] = 'MY_';$config [' composer_autoload'] = FALSE $config ['permitted_uri_chars'] =' a murz 0-9 percent. Config _\ -'; / / before / / $config ['enable_query_strings'] = FALSE;// modified $config [' enable_query_strings'] = TRUE

Here are the rules for nginx rewriting

Location / {

Location / {rewrite "([^ /] {1,}) / {1} ([^ /] {1,})-([^ /] {1,})-([^ /] {1,})" / index.php?c=$1&m=$2_$3_$4 last;rewrite "^ / ([^ /] *) / {0,}" / index.php?c=$1&m=index last;break;}

Break

}

Why do you need to put double quotation marks above? this error occurs when nginx is restarted nginx: [emerg] directive "rewrite" is not terminated by ";" error

Cause of error:

Later, debugging found that this was due to the symbol "{}" in curly braces in the rule, which Nginx mistakenly thought was the end of the rule, resulting in an error.

Solution:

Therefore, in order to avoid this situation, we need to use double quotation marks to identify the pseudo-static rules.

Here are the rules of apache

RewriteEngine onRewriteCond $1! (index.php | admin.php | images | statics | robots.txt) # / de and / de/ can visit RewriteRule ^ ([^ /] *) / {0,} $/ index.php?c=$1&m=index [L] # / de/a-video-b-> / index.php?c=de&m=a_video_bRewriteRule ([^ /] {1,}) / {1} ([^ /] {1,})-([^ /] {1,})-([^ /] {1)-([^ /] {1) }) / index.php?c=$1&m=$2_$3_$4 [L]

-

On the use of the Ci framework url rewriting process is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report