Reputation: 9909
There are several variant questions on this on SO, but I did not find one that answers my specific problem.
I want to add a rewrite rule to my htaccess that will take all traffic going to
http://example.com/blog/its-a-sunny-day
and redirect to
http://example.com
Ideally this should be done via 302, as it will be changed later.
Upvotes: 1
Views: 5496
Reputation: 785246
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^blog/its-a-sunny-day/?$ / [L,R,NC]
Upvotes: 2
Reputation: 9909
Redirect /blog/its-a-sunny-day http://example.com
This seems to work.
Upvotes: 5
Reputation: 7
Create a cgi/php file for sending a redirect header. Then write a rewrite rule to replace "blog/its-a-sunny-day" with "path/to/redirect.php". For example:
/redirect.php:
<?php header( 'Location: /' ) ; ?>
/.htaccess:
RewriteEngine on
RewriteRule ^blog/its-a-sunny-day$ /redirect.php
Upvotes: -3