Welcome to WebmasterWorld Guest from 107.21.141.245

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

.htaccess rule for directory urls

How to redirect urls inside a directory

     
11:30 am on Sep 24, 2013 (gmt 0)

New User

joined:Sept 24, 2013
posts: 1
votes: 0


Hi All,
I've vBulletin forum installed in /forum directory on a website.
I'm trying to redirect /forum/xyz/ to /forum/abc-xyz-def/

I tried this rules but none worked

In the .htaccess file of root
RewriteRule ^forum/xyz/ /forum/abc-xyz-def/ [L,R=301]

I also tried above in the /forum/.htaccess but still didn't work.

any suggestion?
1:03 pm on Sept 24, 2013 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 0


Prefix the target URL with the protocol and hostname.

Request the short URL and watch the browser address bar change the the longer URL.

The code goes in the root htaccess file.
7:43 pm on Sept 24, 2013 (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:12994
votes: 287


Keep all RewriteRules in the primary htaccess. mod_rewrite behaves a little differently from other Apache mods, so you have to treat it with caution.

Before anything else: Does your existing htaccess have other RewriteRules that do work as intended? If you don't know, make up a nonsense rule like

RewriteRule foobar http://www.example.com/widget.html [R=301,L]

and make sure it works. (Look at browser's address bar, not at page content.)

Does the forum use a CMS that uses rewriting? If so, you need to find those rules and make sure your additions go in the right places and don't conflict with existing rules.
9:18 pm on Sept 24, 2013 (gmt 0)

Administrator

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

joined:Aug 10, 2004
posts:10550
votes: 10


welcome to WebmasterWorld, jackjermey!


is that a specific "xyz" or a generic "xyz"?
in other words are you redirecting a specific path or do you need to capture part of the path from the Pattern to reuse in the Substitution string?
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members