Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.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 基于url(也称为DIGG)在数据库中提取数据_Php - Fatal编程技术网

Php 基于url(也称为DIGG)在数据库中提取数据

Php 基于url(也称为DIGG)在数据库中提取数据,php,Php,我甚至很难想出如何写一个谷歌搜索来解决这个问题 如果你点击Digg上的一个故事,它会把它全部放在URL中,比如Digg.com/news/science/why\u thew\u thew\u thew\u world\u tilled,而不是Digg.com/reader.php?r=news&s=science&t=why\u thew\u thew\u thew\u thew\u thew\u tilled 我很确定他们没有几百万个子文件夹,我记得4年前读过一篇文章,解释了它是如何工作的,

我甚至很难想出如何写一个谷歌搜索来解决这个问题

如果你点击Digg上的一个故事,它会把它全部放在URL中,比如
Digg.com/news/science/why\u thew\u thew\u thew\u world\u tilled
,而不是
Digg.com/reader.php?r=news&s=science&t=why\u thew\u thew\u thew\u thew\u thew\u tilled


我很确定他们没有几百万个子文件夹,我记得4年前读过一篇文章,解释了它是如何工作的,但我记不清了,无法再次查找它。

如果您使用的是Apache,您可以使用。我不是这方面的专家,但如果你搜索一些mod_rewrite教程,你可以找到一些示例,其中一个漂亮的URL在web服务器上被有效地转换为一个不同的查询字符串。

如果你使用Apache,你可以使用。我不是这方面的专家,但如果你搜索一些mod_rewrite教程,你可以找到一些示例,其中一个漂亮的URL在web服务器上被有效地转换为一个不同的查询字符串。

有两种基本方法:

  • 让web服务器解析所需数据位的URL,并将其转换为查询字符串;这通常是通过
  • 从环境中获取URI并自己提取所需的位。大多数优秀的web框架都会为您提供这样做的方法
  • 例如,在中,您可以写:

    package My::Application::Controller::News;
    # …
    # :Path without an argument means the root for the controller. 
    # The controller is news so: /news/
    # :Args(2) means with two arguments
    sub article :Path :Args(2) {
        my ( $self, $c, $category, $article_name ) = @_;
        # …
    }
    

    $category
    将填充
    “科学”和
    $article\u name
    并填充
    “世界为什么倾斜”`

    有两种基本方法:

  • 让web服务器解析所需数据位的URL,并将其转换为查询字符串;这通常是通过
  • 从环境中获取URI并自己提取所需的位。大多数优秀的web框架都会为您提供这样做的方法
  • 例如,在中,您可以写:

    package My::Application::Controller::News;
    # …
    # :Path without an argument means the root for the controller. 
    # The controller is news so: /news/
    # :Args(2) means with two arguments
    sub article :Path :Args(2) {
        my ( $self, $c, $category, $article_name ) = @_;
        # …
    }
    

    $category
    将填充
    “科学”和
    $article\u name
    并填充
    “世界为什么倾斜”`

    你所说的是。这种模式通常在MVC体系结构中使用。

    您所说的是。此模式通常在MVC体系结构中使用。

    如果您的服务器运行Apache并安装了mod_rewrite,则可以创建一个名为.htaccess的文件,其中包含以下内容:

    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </IfModule>
    
    
    重新启动发动机
    重写cond%{REQUEST_FILENAME}-F
    重写cond%{REQUEST_FILENAME}-D
    重写规则^(.*)$index.php?q=$1[L,QSA]
    
    这将向var$\u GET['q']中的request index.php发送路径。
    如果路径指向现有文件或目录,则不会将路径发送到index.php。

    如果您的服务器运行Apache并且安装了mod_rewrite,则可以创建一个名为.htaccess的文件,其中包含以下内容:

    <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </IfModule>
    
    
    重新启动发动机
    重写cond%{REQUEST_FILENAME}-F
    重写cond%{REQUEST_FILENAME}-D
    重写规则^(.*)$index.php?q=$1[L,QSA]
    
    这将向var$\u GET['q']中的request index.php发送路径。 如果路径指向现有文件或目录,则不会将路径发送到index.php