Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php程序中创建这样的页面链接?_Php_Apache_.htaccess_Url Rewriting - Fatal编程技术网

如何在php程序中创建这样的页面链接?

如何在php程序中创建这样的页面链接?,php,apache,.htaccess,url-rewriting,Php,Apache,.htaccess,Url Rewriting,例如,在tumblr.com中,页面链接类似于tumblr.com/dashboard/x,并且x表示页码 在php中,我曾经将页面设置为/?page=x 我想知道如何让它像tumblr.com一样工作 我相信这不是php创建的路径。这称为URL重写,可以通过Apache的mod_重写来实现。例如:这称为URL重写,可以通过Apache的mod_重写来实现。例如:在这里,Apache重写模式将解决这个问题。您必须在.htaccess文件 # enable apache morRewrite mo

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

在php中,我曾经将页面设置为
/?page=x

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


我相信这不是php创建的路径。

这称为URL重写,可以通过Apache的mod_重写来实现。例如:

这称为URL重写,可以通过Apache的mod_重写来实现。例如:

在这里,Apache重写模式将解决这个问题。您必须在
.htaccess
文件

# enable apache morRewrite module #
RewriteEngine on
RewriteRule index([0-9]*).ht(m?ml?)$ ?page=$1 [QSA,L]
您的url看起来像
www.example.com/index12.html
上述url中的
12
后索引将被视为
?page=12


希望它有意义

在这里,apache重写模式将解决这个问题。您必须在
.htaccess
文件中添加重写规则

# enable apache morRewrite module #
RewriteEngine on
RewriteRule index([0-9]*).ht(m?ml?)$ ?page=$1 [QSA,L]
您的url看起来像
www.example.com/index12.html
上述url中的
12
后索引将被视为
?page=12


希望它有意义

Try.htaccess,url重写技术在这个网站上搜索“url重写PHP”或“路由PHP”。通常涉及Apache的
mod_rewrite
。可能与Try.htaccess、url重写技术重复。在该网站上搜索“url重写PHP”或“路由PHP”。通常,Apache的
mod_rewrite
都会涉及其中。感谢您的回答,这里有一些问题供您评论。它们看起来像正则表达式。是(m?ml?)可以是(ml?)是的,可以是html或htm,您可以将其更改为如所愿的
index12.aspx
或任何您想要的内容感谢您的回答,但这里有一些问题供您评论。它们看起来像正则表达式。是(m?ml?)可以是(ml?)吗?是的,可以是html或htm,您可以根据需要将其更改为
index12.aspx
或任何您想要的内容