我需要使用.httacess URL参数来改变,我不是太熟悉复杂httacess这就是为什么我需要这方面的帮助。
http://www.gardeningwithangus.com.au/index.php?option=com_plant&view=plant&botanic-name=Wahlenbergia&cultivar=Sky雾和放大器;通用名=原生风信子和放大器;植物ID =
需要改变植物为ID。因此,URL将一些这样的事情
的index.php选项= com_plant和放大器;鉴于=植物放;植物名称=蓝花参属和放大器;品种=天空雾和放大器;通用名=原生风信子和ID =
同样的, http://www.gardeningwithangus.com.au/plants?view=plant&botanic-name=Crowea+exalata&cultivar=Low+Dome&common-name=Crowea&plant-id=
任何帮助,请..!
我的code:
RewriteEngine叙述上
的RewriteCond%{QUERY_STRING} ^(查看=厂)及植物ID =([0-9] *)(?:&放大器; | $)[NC]
重写规则^(分量/株)/ $ / $ 1 /%1安培;?ID =%2 [L,NC,R = 301]
##
#@package的Joomla
#@版权所有版权所有(C)2005至13年开源事项。版权所有。
#@license GNU通用公共许可证第二版或更高版本;看LICENSE.TXT
##
##
#读这家完全如果您选择使用此文件!
#
#只是这部分下面的一行:选项+的FollowSymLinks'可能会导致问题
#与一些服务器配置。据需要使用的mod_rewrite,但可能已经
#由服务器管理员的方式,dissallows改变它的设置
#.htaccess文件。如果使用它会导致你的服务器出错了,把它注释掉(加#号
#开始行),刷新你的网站在您的浏览器测试您的海基会网址。如果他们的工作,
#已设置服务器管理员,你不需要它设置在这里。
##
##可以被注释掉,如果导致错误,见以上说明。
选项+的FollowSymLinks
## mod_rewrite的使用。
RewriteEngine叙述上
##开始 - 重写规则来阻挡一些常见的攻击。
#如果遇到你的网站块以下列出的操作上的问题
#这试图阻止利用`attempts`到Joomla最常见的类型!
#
#阻止任何脚本试图在URL中base64_en code数据。
的RewriteCond%{QUERY_STRING} base64_en code [^(] * ([^)] * )[OR]
#屏蔽掉,其中包括一个与其中任何脚本,脚本>标签的URL。
的RewriteCond%{QUERY_STRING}(小于|%3C)([^ s]的* S)+ CRIPT *。(大于|%3E)[NC,OR]
#阻止任何脚本试图通过URL设置一个PHP GLOBALS变量。
的RewriteCond%{QUERY_STRING} GLOBALS(= | [| %[0-9A-Z] {0,2})[OR]
#阻止任何脚本试图通过URL修改_REQUEST变量。
的RewriteCond%{QUERY_STRING} _ REQUEST(= | [| %[0-9A-Z] {0,2})
#返回403禁止头,并显示根网页的内容
重写规则。*的index.php [F]
#
##完 - 重写规则来阻挡一些常见的攻击。
##开始 - 自定义重定向
#
#如果你需要重定向一些页面,或者设置一个规范的非www到
#WWW重定向(反之亦然),放在这里是code。确保这些
#重定向使用正确的重写规则的语法和[R = 301,L]标志。
#
##结束 - 自定义重定向
##
#取消以下,如果你的网站服务器URL行
#没有直接关系到物理文件路径。
#更新您的Joomla!目录(只/根)。
##
#的RewriteBase /
##开始 - 的Joomla!核心海基会节。
#
。重写规则* - [E = HTTP_AUTHORIZATION:%{HTTP:授权}]
#
#如果所请求的路径和文件不被的index.php并且请求
#尚未内部重写到在index.php脚本
的RewriteCond%{REQUEST_URI}!^ /指数 .PHP
#和该请求是为组件夹内的东西,
#或网站根目录,或为扩展名的URL,或
与所列出的扩展名之一#请求的URL结束
的RewriteCond%{REQUEST_URI} /component/|(/[^.]*|.(php|html?|feed|pdf|vcf|raw))$ [NC]
#和所请求的路径和文件不直接匹配的物理文件
的RewriteCond%{} REQUEST_FILENAME!-f
#和所请求的路径和文件不直接匹配的物理夹
的RewriteCond%{} REQUEST_FILENAME!-d
#内部重写请求的index.php脚本
重写规则。*的index.php [L]
#
##结束 - 的Joomla!核心海基会节。
的RewriteCond%{QUERY_STRING} ^(选项= +?)及(。*)厂-ID = $ [NC]
重写规则^(指数 .PHP)$ $ 1%1安培;?ID =%2 [L,NC,R = 302]
的RewriteCond%{QUERY_STRING} ^(视图= +?)及(。*)植物-ID = $ [NC]
重写规则^(厂)$ $ 1%1安培;?ID =%2 [L,NC,R = 302]
解决方案
假设查询参数是给定顺序的问题。的
启用的mod_rewrite
和的.htaccess
到的httpd.conf
(如果尚未启用),然后把这个code在 DOCUMENT_ROOT /的.htaccess
文件:
RewriteEngine叙述上
的RewriteCond%{QUERY_STRING} ^(选项= +?)及(。*)厂-ID = $ [NC]
重写规则^(指数 .PHP)$ $ 1%1安培;?ID =%2 [L,NC,R = 302]
的RewriteCond%{QUERY_STRING} ^(视图= +?)及(。*)植物-ID = $ [NC]
?重写规则^(植物|组件/株)/ $ $ 1%1和ID =%2 [L,NC,R = 302]
I need to change url parameters using .httacess , i am not too much familiar with complex httacess thats why i need help regarding this .
http://www.gardeningwithangus.com.au/index.php?option=com_plant&view=plant&botanic-name=Wahlenbergia&cultivar=Sky Mist&common-name=Native Bluebell&plant-id=
need to change plant-id to id. So url will some thing like that
index.php?option=com_plant&view=plant&botanic-name=Wahlenbergia&cultivar=Sky Mist&common-name=Native Bluebell&id=
Same with
http://www.gardeningwithangus.com.au/plants?view=plant&botanic-name=Crowea+exalata&cultivar=Low+Dome&common-name=Crowea&plant-id=
Any help please.. !
My Code:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(view=plant)&plant-id=([0-9]*)(?:&|$) [NC]
RewriteRule ^(component/plant)/?$ /$1/?%1&id=%2 [L,NC,R=301]
##
# @package Joomla
# @copyright Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.
# @license GNU General Public License version 2 or later; see LICENSE.txt
##
##
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
##
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
## Mod_rewrite in use.
RewriteEngine On
## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*([^)]*) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects
##
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##
# RewriteBase /
## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.
RewriteCond %{QUERY_STRING} ^(option=.+?)&plant-id=(.*)$ [NC]
RewriteRule ^(index.php)$ $1?%1&id=%2 [L,NC,R=302]
RewriteCond %{QUERY_STRING} ^(view=.+?)&plant-id=(.*)$ [NC]
RewriteRule ^(plants)$ $1?%1&id=%2 [L,NC,R=302]
解决方案
Assuming query parameters are in the given order as the question.
Enable mod_rewrite
and .htaccess
through httpd.conf
(if not already enabled) and then put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(option=.+?)&plant-id=(.*)$ [NC]
RewriteRule ^(index.php)$ $1?%1&id=%2 [L,NC,R=302]
RewriteCond %{QUERY_STRING} ^(view=.+?)&plant-id=(.*)$ [NC]
RewriteRule ^(plants|component/plant)/?$ $1?%1&id=%2 [L,NC,R=302]