我正在将现有的旧网址重定向到新的网址链接,我尝试使用以下代码
Redirect 302 /about-us-company http://xyz./pharmaceutical-manufacturing-company
它正在重定向到新的网址,但在新网址的末尾,以前的网址链接还附加了如何删除之前的网址
输出: 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 ##
答案 0 :(得分:0)
开箱即用
RewriteCond %{REQUEST_URI} about-us-company/$
RewriteRule ^about-us-company/ http://xyz.pharmaceutical-manufactuturing-company [L,R=302]
答案 1 :(得分:0)
对于单个网址,请使用此代码
Redirect 301 /old/old.htm http://www.yournew.com/new.htm
答案 2 :(得分:0)
Redirect指令将旧网址的其余部分附加到其目标目标。您可以使用RedirectMatch
代替Redirect
来摆脱尾随的旧路径
RedirectMatch 302 /about-us-company http://xyz./pharmaceutical-manufacturing-company
答案 3 :(得分:0)
在目标末尾使用?
以防止查询字符串附加如下:
RewriteEngine on
RewriteRule ^about-us-company http://example.com/pharmaceutical-manufacturing-company? [L,R]