For that particular example:
Redirect 301 /page.php?area_id=1 /about-us
Thread Starter
bjh555
(@bjh555)
Hi Joseph (again)
Thanks for the reply, this doesn’t seem to work though. It isn’t trying to redirect at all…
I’ve put it before and after the WordPress bit in the .htaccess file but no joy
B
Try this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Redirect 301 /page.php?area_id=1 /about-us
</IfModule>
Thread Starter
bjh555
(@bjh555)
Still no joy, this is my htaccess file…
# 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]
Redirect 301 /page.php?area_id=1 /about-us
</IfModule>
# END WordPress
My mistake. I’ve just check the apache documentation and the syntax is
Redirect [status] URL-path URL
therefore it should be:
Redirect 301 /page.php?area_id=1 http://yourdomain/about-us
Thread Starter
bjh555
(@bjh555)
Hi Joseph
Thanks for looking into this, still doesn’t work though…
Stumped!
Cheers
B
Thread Starter
bjh555
(@bjh555)
I was just tinkering and did this…
Redirect 301 /page.php http://www.domain.com/
and when you go to http://www.domain.com/page.php?area_id=1 it redirects to http://www.domain.com/?area_id=1
It’s not right or what I want but at least the redirect is working…
Is there something difficult with redirecting the area_id=1 bit?
Cheers
You need to use RewriteCond to redirect urls with query parameters
RewriteCond %{QUERY_STRING} ^area_id=1$
RewriteRule ^/page\.php$ http://www.domain.com/about-us/ [L,R=301]
Check http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond for more info
Hope this helps…
Thread Starter
bjh555
(@bjh555)
Hi Reuben
Thanks for the reply.
This is my htacess file but it’s not working still…
SetEnv DEFAULT_PHP_VERSION 5
# 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]
RewriteCond %{QUERY_STRING} ^area_id=1$
RewriteRule ^/page\.php$ http://www.domain.com/about-us/ [L,R=301]
</IfModule>
# END WordPress
Am I doing something wrong or is it because of having other RewriteCond’s?
is the .htaccess file present in the same directory as page.php?. Also, do you have http://www.domain.com or your real domain in your .htaccess file?
Thread Starter
bjh555
(@bjh555)
Hi Reuben
page.php doesn’t exist – it’s an old page from the old pre-wordpress website so can’t sit in the same directory.
I do have our real domain in the .htaccess file 🙂
I just tried with a different one and this worked Redirect 301 /press_releases.php http://www.ourdomain.com/news
Totally stumped and rather worried about potential search engine losses…
B
Place the 301 redirect rule above the WordPress rule and see if it works.
SetEnv DEFAULT_PHP_VERSION 5
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^area_id=1$
RewriteRule ^/page\.php$ http://www.domain.com/about-us/ [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress