Welcome to WebmasterWorld Guest from 34.204.168.57

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

.htaccess file not working as it should

     
12:58 pm on Aug 5, 2014 (gmt 0)

Junior Member

10+ Year Member

joined:May 13, 2005
posts:60
votes: 0


Hi Everyone,

I have been a member for quite some time and this is my first post in a while.

I am trying to get my .htaccess file to issue redirects for thousands of URLs and whatever I am doing is not working.

Below is the code in my .htaccess file

# Permanent move from website1.com to website2.com
RewriteEngine On

RewriteRule ^/tigers/(.+) http://website2.com/bears/$1 [R=301,L]


What I was hoping this would do was redirect website1.com/tigers/xxxx to website2.com/bears/xxxx where xxxx can be any of thousands of different names. However what is happening is that I am being redirected from website1.com/tigers/xxxx to website2.comtigers/xxxx where "tigers" is not being replaced by "bears" and a "/" is missing in front of the url.

Any help would be appreciated

[edited by: phranque at 1:49 pm (utc) on Aug 5, 2014]
[edit reason] unlinked URL [/edit]

1:29 pm on Aug 5, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Oct 15, 2004
posts:942
votes: 0


RewriteRule ^tigers/(.+)$ http://website2.com/bears/$1 [R=301,L] 


something like this perhaps?
1:48 pm on Aug 5, 2014 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3150
votes: 4


omoutop's suggestion is sound, however, I can't see how your current RewriteRule is redirecting anything. It shouldn't match anything and consequently fail silently... because of the slash prefix on the RewriteRule pattern (the directory prefix is removed in per-directory .htaccess files) before the pattern is matched.

Original RewriteRule:
RewriteRule ^/tigers/(.+) http://website2.com/bears/$1 [R=301,L]

website1.com/tigers/xxxx to website2.comtigers/xxxx


?
6:41 pm on Aug 5, 2014 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15900
votes: 876


RewriteRule ^/

This will always fail in htaccess (or <Directory> sections in config). Leave off the initial slash.

Incidentally, you can say example.org, example.net, example.xyz, example.abc and so on if you need to distinguish among different names. Any tld, including ones that don't exist. No subdomains, though.