繁体   English   中英

htaccess中的网址从旧网址重定向到新网址

[英]Url redirect in htaccess from old url to new url

我将现有的旧URL重定向到新的URL链接,我尝试使用以下代码

Redirect 302 /about-us-company http://xyz./pharmaceutical-manufacturing-company

它正在重定向到新URL,但是在新URL的末尾,上一个URL链接也附加了如何删除上一个URL。

输出: http : //xyz./pharmaceutical-manufacturing-company?/about-us-company

htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
RewriteRule ^about-us-company    http://www.example.com/pharmaceutical-manufacturing-company? [L,R]
Redirect 301 /products http://www.example.com/pharmaceutical-products?
Redirect 301 /csr http://www.example.com/corporate-social-responsibility?
Redirect 301 /research http://www.example.com/pharmaceutical-formulation-development?
Redirect 301 /news http://www.example.com/latest-news-events?
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

盒子外面

RewriteCond %{REQUEST_URI} about-us-company/$
RewriteRule ^about-us-company/ http://xyz.pharmaceutical-manufactuturing-company [L,R=302]

对于单个网址,请使用此代码

Redirect 301 /old/old.htm http://www.yournew.com/new.htm

重定向指令将剩余的旧url附加到其目标目标。 您可以使用RedirectMatch而不是Redirect摆脱尾随的旧路径

RedirectMatch 302 /about-us-company http://xyz./pharmaceutical-manufacturing-company

使用? 在目标末尾以防止查询字符串像这样追加:

RewriteEngine on
RewriteRule ^about-us-company    http://example.com/pharmaceutical-manufacturing-company? [L,R]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM