与重写的.htaccess的URL [英] Rewriting an URL with .htaccess
问题描述
面临诸多问题与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 $ C $运行C>键,并使得文件的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
.
这篇关于与重写的.htaccess的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!