简体   繁体   中英

301 redirect - old domain to new not working with non www

I'm trying to redirect my old website f1arab.com to formulawahad.com with all the links inside. I used Wordpress which is installed in the wp_ar folder.

I put with a help of a friend this code in the htaccess that is available in the root (not wp_ar) but it seems to work only without "www" and it doesn't redirect inside links like f1arab.com/news/111 to formulawahad.com/news/111.

How can I achieve that?

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

RewriteEngine On
RewriteCond %{HTTP_HOST} ^f1arab\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.formulawahad\.com$
RewriteRule (.*)$ http://www.formulawahad.com/$1 [R=301,L]

php_value memory_limit 1024M

<Files "config.php">
Order Allow,Deny
Deny from All

Thanks everyone.

Adding this as the htaccess for the f1arab.com site should work. It will redirect all pages going to the old website to the new website (so f1arab.com/about will be directed to www.formulawahad.com/about .

RewriteEngine on
RewriteRule ^(.*)$ http://www.formulawahad.com/$1 [R=301,L]

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.

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