与重写的.htaccess的URL重写、htaccess、URL

由网友(我的黑名单欢迎你)分享简介:面临诸多问题与htaccess的重写规则后,因为它是目前我已经决定改变它的东西更基本的,但我不能得到最终页面拿起ID。After facing many problems with the htaccess rewrite rule as it is at the moment I have decided to c...

面临诸多问题与htaccess的重写规则后,因为它是目前我已经决定改变它的东西更基本的,但我不能得到最终页面拿起ID。

After facing many problems with the htaccess rewrite rule as it is at the moment I have decided to change it to something more basic but I cannot get the end page to pick up the ID.

我的.htaccess是:

My .htaccess is:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST) /article.php?issue=(.*)&edition=(.*)&id=(.*)&title=(.*) HTTP
RewriteRule ^ /article/%2/%3/%4/%5? [R=302,L]
RewriteRule ^article/(.*)/(.*)/(.*)/(.*)$ /article.php?issue=$1&edition=$2&id=$3&title=$4 [L]

如何获取文章页面拿起身份证号码?

How do I get the article page to pick up the ID number?

推荐答案

您可以使用此code:

You can use this code:

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{THE_REQUEST} s/article.php?issue=([^&]*)&edition=([^&]*)&id=([^&]*)&title=([^&s]*)
RewriteRule ^ /article/%1/%2/%3/%4? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^article/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /article.php?issue=$1&edition=$2&id=$3&title=$4 [L,QSA,NC]

使用 -MultiViews 是非常重要的位置。选项​​多视​​图所使用的 Apache的内容协商模块之前的mod_rewrite 键,并使得文件的Apache服务器匹配扩展。因此, /文件可以在URL,但它将成为 /file.php

Use of -MultiViews is very important here. Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.