i want to do 301 redirection with the search query.
for example: abc.com should redirect to abc.org and if someone suppose to enter abc.com/xyz.html then it must also redirect to abc.org/xyz.html
below is the current htaccess part.
RewriteRule pages/(.*) single.php?page=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^rss.xml$ rss.php [L]
RewriteRule (.*)\.html song.php?q=$1 [L,QSA]
Your current rules seem to be faulty since RewriteCond
only applies to very next RewriteRule
. With the new rule have your complete .htaccess like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^ http://www.newdomain.com%{REQUEST_URI} [ [R=301,L,NE]
RewriteRule ^pages/(.*)$ single.php?page=$1 [L,QSA,NC]
RewriteRule ^rss\.xml$ rss.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^.]+)\.html$ song.php?q=$1 [L,QSA,NC]
Assuming that the directory structure stayed the same between domains, you can do this via the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
If the directory structure DID change, you can use additional rules on the NEW domain's .htaccess
file to map appropriately.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.