Mod Rewrite help Needed

Using mod_rewrite to handle various content issues

Mod Rewrite help Needed

Postby Caveman » Sun Mar 20, 2005 8:15 pm

Hi,
I recently upgraded my forums to vbulletin and moved them from the root directory to a sub domain. All my previous pages that were indexed in the search engines are now hitting the portal I installed in the root dir. I am trying to find a way to redirect all search engine traffic to the sub domain, but let any other kind of traffic land at the portal. Is this possible? I've tried several different variations in .htaccess, but they all either show 404 or 500.
Caveman
 

Postby Caterham » Mon Mar 21, 2005 6:29 pm

I've tried several different variations in .htaccess, but they all either show 404 or 500.
And which one? :-?

I cannou guess what your problem was... :wink2:
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Mod Rewrite help Needed

Postby Caveman » Mon Mar 21, 2005 11:07 pm

Caterham wrote:
I've tried several different variations in .htaccess, but they all either show 404 or 500.
And which one? :-?

I cannou guess what your problem was... :wink2:
Thanks for the reply Caterham. I've tried so many different variations, I wouldn't even know where to start to list them.

What I need to do is 301 redirect all my SE indexed pages that begin with http://www.mydomain.com/forumxx.php (where xx is a numerical value) to http://forum.mydomain.com/forumdisplay.php?f=xx (where xx is a numerical value). Is there a way to do this via .htaccess?

Thanks,
Mike
Caveman
 

Postby Caterham » Tue Mar 22, 2005 5:59 am

http://www.mydomain.com/forumxx.php
301 redirect all my SE indexed pages that begin with http://www.mydomain.com/forumxx.php (where xx is a numerical value) to http://forum.mydomain.com/forumdisplay.php?f=xx
This should work with
Code: Select all
RewriteEngine On
RewriteRule ^forum([0-9]+)\.php$ http://sub.example.com/forumdisplay.php?f=$1 [R=301,L]
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Caveman » Tue Mar 22, 2005 4:16 pm

That one's not working either. Get a 404 with it.
Caveman
 

Postby Caterham » Wed Mar 23, 2005 1:52 am

Make sure that you can use mod_rewrite in .htaccess files. Open httpd.conf and enable
Code: Select all
AllowOverride FileInfo
for your <Directory>-Container
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Caveman

Postby Guest » Wed Mar 23, 2005 12:06 pm

I know mod rewrite in the .htaccess works. I was using it to rewrite url's in phpbb. I don't have access to httpd.conf. Is there another way to do it via .htaccess?
Guest
 

Re: Caveman

Postby Caveman » Wed Mar 23, 2005 5:49 pm

Anonymous wrote:I know mod rewrite in the .htaccess works. I was using it to rewrite url's in phpbb. I don't have access to httpd.conf. Is there another way to do it via .htaccess?
whoops, that was from me.
Caveman
 

Postby Caterham » Wed Mar 23, 2005 7:04 pm

well, the pattern should work:
^forum([0-9]+)\.php$

starts with foum followed by 1 to n chars of 0-9, a dot and php at the end of the string.
It should be placed in the directory where the forumxx.php was before.

You can try a rewrite base, but it's not nessecary unless you're using Aliases from mod_alias or homedirs from mod_userdir.

RewriteEngine On
RewriteBase /
RewriteRule ^forum([0-9]+)\.php$ http://sub.example.com/forumdisplay.php?f=$1 [R=301,L]
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Caveman » Thu Mar 24, 2005 10:48 am

No, it's still hitting a 404. I've got all traffic from the SE going to the forum index now by using the following
Code: Select all
ErrorDocument 404 /redir.php
and in redir.php I have
Code: Select all
<?php
header("HTTP/1.0 301 Moved");
header("Location: http://forum.example.com");
?>
This is probably not the best solution, but at least it's working. Do you have any other ideas on this?

Thanks
Caveman
 


Return to Content

Who is online

Users browsing this forum: No registered users and 7 guests

cron