简体   繁体   English

用PHP重写URL

[英]URL re-writing in PHP

I am trying to implement URL rewriting in my PHP application. 我正在尝试在我的PHP应用程序中实现URL重写。 Can someone share a step by step procedure of implementing URL rewriting in PHP 有人可以分享在PHP中实现URL重写的分步过程吗

In my application I want to implement following URL rewriting 在我的应用程序中,我想实现以下URL重写

http://example.com/fast-five
http://example.com/300
http://example.com/13-b

from

http://example.com/movie-download.php?nm=fast-five
http://example.com/movie-download.php?nm=300
http://example.com/movie-download.php?nm=13-b

One more thing which URL will be best according to SEO, management, application point-of-view out of the following two types. 根据以下两种类型中的SEO,管理,应用程序的观点,哪个URL最好是另一件事

Of course 当然

http://example.com/fast-five

will be good for SEO 对SEO有好处

Are you serving your PHP through an Apache HTTP Server installation? 您是否通过Apache HTTP Server安装来提供PHP? If so: 如果是这样的话:

RewriteRule ^/fast-five$ /movie-download.php?nm=fast-five [R=301]

From an SEO perspective, the first would be preferred. 从SEO的角度来看,第一个将是首选。 Using the HTTP 301 ("Moved Permanently") is most effective for this. 为此,使用HTTP 301(“永久移动”)最有效。

If your using an MVC framework like CakePHP, you should look at the documentation on routing . 如果您使用的是CakePHP之类的MVC框架,则应该查看routing上的文档 Otherwise, you can use the web servers rewriting rules . 否则,您可以使用Web服务器重写规则

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM