Rewriting URL on Apache [Not finished]
来源:互联网 发布:知乎 阿提哈德航空 编辑:程序博客网 时间:2024/06/14 09:30
Resume
It’s very common to do the URL rewriting while we are developing a site. Thus, many people wants to do this to make their site more beautiful. However, some of the tutorials are too complicated. This passage will tell you how to rewrite URL on Apache as easy as possible.
.htaccess
For instance, if we have blog.php
in the directory blog
. And we want to redirect a URL like http://example.com/blog/123
to http://example.com/blog/blog.php?id=123
. Then we need to do the URL rewriting.
/blog ./blog.php
First of all, create a file called .htaccess
in the directory that you want to rewrite.
Then, if you haven’t enabled the URL rewriting generally, write RewriteEngine On
in your .htaccess
file to enable URL rewriting.
Create rules
Then, in our .htaccess
file, just simply type RewriteRule ^blog/([0-9]+) blog.php?id=$1
.
Some readers may already know that the ([0-9]+)
is the regular expression which means that we are allowed to define what we want to accept in the URL.
Moreover, $1
means we take the first regexp as a variable.
TO BE CONTINUE…
- Rewriting URL on Apache [Not finished]
- Apache URL Rewriting 技巧及实例
- Making URL rewriting on IIS 7 work like IIS 6
- URL ReWriting 示例(C#)
- IIS Url ReWriting 示例
- Url ReWriting 示例
- Url ReWriting 示例
- URL Rewriting 重写解决方案
- URL Rewriting 重写解决方案
- Servlet URL Rewriting
- org.apache.subversion.javahl.ClientException: Previous operation has not finished
- org.apache.subversion.javahl.ClientException: Previous operation has not finished
- org.apache.subversion.javahl.ClientException: Previous operation has not finished
- org.apache.subversion.javahl.ClientException: Previous operation has not finished
- URL rewriting issue when postbacks and URL rewriting
- php-url-rewriting-with-htaccess-and-microsoft-iis-url-rewriting
- Url Rewriting with ASP.NET
- Url Rewriting后的问题
- LeetCode 100. Same Tree
- 冒泡排序及二分查找
- 将一个数组赋值给另外一个数组
- MPU6050
- 清晰解题: 网易编程地牢逃脱
- Rewriting URL on Apache [Not finished]
- Kafka Broker HA机制
- 如何在CSDN中显示代码块
- 开启本地https端口--使用keytool
- java-基础--TCP/IP协议
- CentOS 6 的安全配置(CentOS Linux服务器安全设置)
- 获取包含中英文的字符串的自然长度
- fwrite和fread函数的用法小结
- MySQL修改root密码的多种方法