简体   繁体   中英

301 redirect on .htaccess not working with Wordpress

I've got below 301 redirect the bottom one I would like to get it working but it's not working at the moment.

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

# END WordPress
RewriteCond %{HTTP_HOST} ^domain.com.au$
RewriteRule ^/?$ "http\:\/\/www\.domain\.com\.au\/" [R=301,L]
RewriteRule ^author/privacy?$ privacy [R=301,L]

Is there a reason why?

I would like to redirect author/privacy to privacy...

Order of the rules is of problem here. Here is the fixed version:

# BEGIN WordPress
<IfModule mod_rewrite.c>

Options +FollowSymLinks +Indexes
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^domain\.com\.au$ [NC]
RewriteRule ^$ http://www.domain.com.au/ [R=301,L]

RewriteRule ^author/(privacy)/?$ /$1 [R=301,L,NC]

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
# END WordPress

Just had the same problem, but this is the answer..... Use relative URL's not full http:// etc. Cut the below code and add to your .htaccess file and add to your root directory

Redirect 301 /page1.php /page2.html
Redirect 301 /page3.php /page4.html


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

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