如何在这个php程序中进行页面链接?

时间:2013-06-06 12:26:30

标签: php apache .htaccess url-rewriting

例如,在tumblr.com中,页面链接类似于tumblr.com/dashboard/xx表示页码。

在php中,我曾经像/?page=x一样设置页面。

我想知道如何让它像tumblr.com一样工作?

我确实认为这不是php创建的路径。

2 个答案:

答案 0 :(得分:2)

这称为URL重写,可以使用Apache的mod_rewrite实现,例如:http://httpd.apache.org/docs/current/mod/mod_rewrite.html

答案 1 :(得分:1)

这里你的apache重写模式将处理这个你必须在.htaccess文件中添加重写规则

# enable apache morRewrite module #
RewriteEngine on
RewriteRule index([0-9]*).ht(m?ml?)$ ?page=$1 [QSA,L]

你的网址看起来像www.example.com/index12.html 上述网址中的12后索引将视为?page=12

希望它有意义