Mobile app version of vmapp.org
Login or Join
Alves908

: .htaccess 301 rewrite rule not working I had made the page the-book.html in wordpress site, later changed the name to about-the-book, now i have written the .htaccess file as **RewriteRule ^the-book.html$

@Alves908

Posted in: #Htaccess #ModRewrite #Wordpress

I had made the page the-book.html in wordpress site, later changed the name to about-the-book, now i have written the .htaccess file as

**RewriteRule ^the-book.html$ www.conversationissexy.com/about-the-book/ [R=301]**

# 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


but it doesn't works..

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Alves908

1 Comments

Sorted by latest first Latest Oldest Best

 

@Gloria169

1. Try adding [L] flag next to R=301 -- right now redirect will not occur straight away and URL gets processed by other rules (the WordPress block). The L flag in conjunction with R=3xx tells Apache to execute such redirect immediately:

RewriteRule ^the-book.html$ www.conversationissexy.com/about-the-book/ [R=301,L]


This should do the job.

2. If still nothing -- move the above rule inside WordPress block and place just after RewriteBase line:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# your redirect rule
RewriteRule ^the-book.html$ www.conversationissexy.com/about-the-book/ [R=301,L]

# actual WordPress rules
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


3. Alternatively, use RedirectMatch directive instead of RewriteRule so you can keep your redirect rule where it is right now:

RedirectMatch 301 ^/the-book.html$ www.conversationissexy.com/about-the-book/

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme