与重写的.htaccess的URL [英] Rewriting an URL with .htaccess

查看:101
本文介绍了与重写的.htaccess的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

面临诸多问题与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.

这篇关于与重写的.htaccess的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆