[英]Rewrite Problen .htaccess Redirect 301
我需要在网站上放置重定向,并且存在一些问题。
我有这个原始的.htccess
RewriteEngine on
RewriteCond %{REQUEST_URI} \.json$ [NC]
RewriteRule .* - [F,L]
RewriteRule config/.* - [F,L]
RewriteRule config - [F,L]
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule ^.+$ - [L]
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^([^?]+)$ /novo-site/index.php?url
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^$ /novo-site/index.php
AddHandler php54-script .php
suPHP_ConfigPath /home/personalglass1/site02/novo-site/
我输入了最后4行以提供这5页的重定向。
结果是这样的:
RewriteEngine on
RewriteCond %{REQUEST_URI} \.json$ [NC]
RewriteRule .* - [F,L]
RewriteRule config/.* - [F,L]
RewriteRule config - [F,L]
RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC]
RewriteRule ^.+$ - [L]
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^([^?]+)$ /novo-site/index.php?url=$1
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^$ /novo-site/
AddHandler php54-script .php
suPHP_ConfigPath /home/personalglass1/site02/novo-site/
Redirect 301 /sobre-a-personal-evolution /sobre/
Redirect 301 /fechamento-de-sacadas-e-varandas /produto/envidracamento/
Redirect 301 /revendedores-autorizados /revendedores/
Redirect 301 /entre-em-contato /contato/
Redirect 301 /fotos-de-sacadas-evolution /galerias/
但是当我请求该页面时: http : //example.com/sobre-a-personal-evolution
我收到了这个消息: http : //example.com/sobre/?url=sobre-a-personal-evolution
但是对我来说正确的方法是:http:// example.com/sobre/
是第一个请求时我需要的最后一个。
我尝试了一些更改,但没有任何效果!
有人可以帮助我解决这个问题并解释如何做到这一点,我需要了解如何做到这一点。
谢谢!
匹配的URL-Path之外的其他路径信息将附加到目标URL。
“其他路径信息”有些模糊,但是我认为它们是指url
参数。
现在,这根本不影响功能,因此我再次假设您只是不喜欢URL的外观。
但是,由于无论如何都使用mod_rewrite
,因此可以通过RewriteRule
获得与Redirect
相同的效果:
RewriteRule ^/sobre-a-personal-evolution(?:/(.*))?$ /sobre/$1 [R=301,L]
您不得将mod_rewrite
规则与mod_alias
规则混合使用,并在内部重写规则之前保留重定向规则:
RewriteEngine on
RewriteRule \.json$ - [F,L,NC]
RewriteRule config(/|$) - [F,L,NC]
RewriteRule ^sobre-a-personal-evolution /sobre/ [L,NC,R=301]
RewriteRule ^fechamento-de-sacadas-e-varandas /produto/envidracamento/ [L,NC,R=301]
RewriteRule ^revendedores-autorizados /revendedores/ [L,NC,R=301]
RewriteRule ^entre-em-contato /contato/ [L,NC,R=301]
RewriteRule ^fotos-de-sacadas-evolution /galerias/ [L,NC,R=301]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.+)$ /novo-site/index.php?url=$1 [L,QSA]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ /novo-site/ [L]
AddHandler php54-script .php
suPHP_ConfigPath /home/personalglass1/site02/novo-site/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.