伪静态网址除了 .htaccess 和 模板中连结要改,还有什么需要注意?
最近站点想将网址改成伪静态网址
在.htaccess做了以下的设定,
RewriteEngine on
RewriteRule news/([1-9]+[0-9]*)$ news_info.php?id=$1
RewriteRule news/([1-9]+[0-9]*)/$ news_info.php?id=$1
手动输入: 网址/news/123/
已经可以成功去了,当然CSS路径等就要修改一下了,
另外就是需要改模板相关的连结?
比如新闻列表中,把连去 news_info.php?id=$_GET["id"] 改成 /news/$_GET["id"]/
所以...
第一步: 设定.htaccess
第二步:修改模板中的连结?
这样有错吗? 还是应该有更多的事要做?
另外,这样的话,对主机消耗和负载影响大不大?
回复讨论(解决方案)
还是应该把他们做成自动转跳统一?
自动转跳应该用.htaccess还是php?
1.使用了rewrite(正则),对CPU会有一些占用,但影响不大。
2.模版中的连接(内连)最好写一个方法去做。
例如
/news.php?id=123 rewrite为 /news/123
echo 'NEW List';
function url($file, $id){
return $file.'/'.$id;
}
如有一天不想使用rewrite了 url想用回 /news.php?id=123
则只需要修改
function url($file, $id){
return $file.'.php?id='.$id;
}
这样不用每个url都改一次了。
1.使用了rewrite(正则),对CPU会有一些占用,但影响不大。
2.模版中的连接(内连)最好写一个方法去做。
例如
/news.php?id=123 rewrite为 /news/123
echo 'NEW List';
function url($file, $id){
return $file.'/'.$id;
}
如有一天不想使用rewrite了 url想用回 /news.php?id=123
则只需要修改
function url($file, $id){
return $file.'.php?id='.$id;
}
这样不用每个url都改一次了。
明白
谢谢!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

If you want to check some relevant information in Steam or share some website links with friends, how do you do it? Can I enter a URL into steam? Of course it is possible. Below I will teach you how to open a URL in Steam. Specific methods: 1. First, we open steam. 2. Click the Settings option. 3. Then switch to the interface tab. 4. Check Show address bar. 5. Then enter the URL in the address bar to use the browser.

PHP URL detection refers to using the PHP programming language to verify whether the input string conforms to the format of the URL. Methods to detect URLs: 1. Use regular expressions for URL verification. You can use the "preg_match" function to perform regular matching, if the URL matches the pattern; 2. Use built-in functions for URL verification, use the "filter_var" function and "FILTER_VALIDATE_URL" ” filter to verify.

Regarding PPT masking, many people must be unfamiliar with it. Most people do not understand it thoroughly when making PPT, but just make it up to make what they like. Therefore, many people do not know what PPT masking means, nor do they understand it. I know what this mask does, and I don’t even know that it can make the picture less monotonous. Friends who want to learn, come and learn, and add some PPT masks to your PPT pictures. Make it less monotonous. So, how to add a PPT mask? Please read below. 1. First we open PPT, select a blank picture, then right-click [Set Background Format] and select a solid color. 2. Click [Insert], word art, enter the word 3. Click [Insert], click [Shape]

C++ template specializations affect function overloading and rewriting: Function overloading: Specialized versions can provide different implementations of a specific type, thus affecting the functions the compiler chooses to call. Function overriding: The specialized version in the derived class will override the template function in the base class, affecting the behavior of the derived class object when calling the function.

Did you know that using templates can make you faster at note-taking and more effective at capturing important ideas? OneNote has a set of ready-made templates for you to use. The best part is that you can also design the template according to your needs. Whether you are a student, a corporate warrior or a freelancer doing creative work. OneNote templates can be used to record important notes in a structure and format that suits your style. A template can be an outline of a note-taking process. Amateurs just take notes, professionals take notes and draw connections from them through well-structured notes with the help of templates. Let's see how to use templates in OneNote. Use Default OneNote Template Step 1: Press Windows+R on your keyboard. Type Oneno

In-depth analysis of the role and usage of the static keyword in C language. In C language, static is a very important keyword, which can be used in the definition of functions, variables and data types. Using the static keyword can change the link attributes, scope and life cycle of the object. Let’s analyze the role and usage of the static keyword in C language in detail. Static variables and functions: Variables defined using the static keyword inside a function are called static variables, which have a global life cycle

PHP email templates: Customize and personalize your email content With the popularity and widespread use of email, traditional email templates can no longer meet people's needs for personalized and customized email content. Now we can create customized and personalized email templates by using PHP programming language. This article will show you how to use PHP to achieve this goal, and provide some specific code examples. 1. Create an email template First, we need to create a basic email template. This template can be an HTM

Flask-Bootstrap: Adding templates to Flask applications Flask is a lightweight Python web framework that provides a simple and flexible way to build web applications. It is a very popular framework, but its default templates have limited functionality. To create attractive user interfaces, use additional frameworks or libraries. This is where Flask-Bootstrap comes in. Flask-Bootstrap is a Twitter-based
