Welcome to WebmasterWorld Guest from 54.146.174.220

Forum Moderators: Ocean10000 & incrediBILL & phranque

is this .htaccess correct?

   
4:25 pm on May 12, 2009 (gmt 0)

10+ Year Member



hello guys/gals,

is this .htaccess code correct? I wish to redirect all contents of some directories(which is deleted now) to one file:

----------------------------
redirectMatch 301 ^/offices/ http://www.example.com/mix/contact.htm

redirectMatch 301 ^/contactus/ http://www.example.com/mix/contact.htm

redirectMatch 301 ^/us/ http://www.example.com/mix/contact.htm

redirectMatch 301 ^/apply/ http://www.example.com/mix/contact.htm

redirectMatch 301 ^/contact_us/ http://www.example.com/mix/contact.htm

redirectMatch 301 ^/OurGroup/ http://www.example.com/mix/contact.htm

redirectMatch 301 ^/pi/ http://www.example.com/mix/contact.htm

redirectMatch 301 ^/Our Group/ http://www.example.com/mix/contact.htm

redirectMatch 301 ^/our group/ http://www.example.com/mix/contact.htm
----------------------------

[edited by: engine at 5:08 pm (utc) on May 12, 2009]
[edit reason] please use example.com [/edit]

6:42 pm on May 12, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Did you test it? Did it work? We're not really set up to do code reviews here and prefer to address specific problems. But it looks fine other than an un-escaped space character and the non-standard casing of the RedirectMatch directives.

You could however simplify and reduce the size of this code to a single line by taking advantage of the power of regular expressions:


RedirectMatch 301 ^/(offices¦contact_?us¦us¦apply¦[Oo]ur\ ?[Gg]roup¦pi)/ http://www.example.com/mix/contact.htm

Replace the broken pipe "¦" characters above with solid pipes before use; Posting on this forum modifies the pipe characters.

Jim

6:58 pm on May 12, 2009 (gmt 0)

10+ Year Member



Thank you jim, the problem is that this code did not work... to be specific, worked on hostmonster, but did not on godaddy (linux) ...

I'll try your code definitely...
what do you mean in "solid pipes " ? I?... l?... ¦?...

thank you once more..

8:01 pm on May 12, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Solid pipe: ASCII or UTF-8 code %7C

If your code didn't work, then my code probably won't work either, since it's just a "tweak" of yours. It is possible that GD didn't load mod_alias on that server (ask them), and so RedirectMatch and other directives handled by that module won't be available. You could use mod_rewrite as an alternate.

Jim

9:12 am on May 13, 2009 (gmt 0)

10+ Year Member



thank you jim
10:25 am on May 15, 2009 (gmt 0)

10+ Year Member



Hello Jim and other forum members,

I contacted godaddy and they refused to help me :

"we do not provide support for third-party scripting issues you may be experiencing. You may wish to consult with a community forum online or do a search on your favorite search engine as other users may have encountered a similar question in the past and may offer helpful solutions."

can you give me any alternative of htaccess? or alternate code in htaccess itself?... or just what should I do to redirect the whole folders to a single file?

3:27 pm on May 15, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Don't describe your problem to GoDaddy at all. Just ask them if Apache mod_alias is installed and usable on your type of hosting account.

If the answer is yes, then there is a problem with your code -- most likely that the URL-path pattern is incorrect.

If the answer is no, then as I said above, try using mod_rewrite. Code in example.com/.htaccess :


Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteRule ^(offices¦contact_?us¦us¦apply¦[Oo]ur\ ?[Gg]roup¦pi)/ http://www.example.com/mix/contact.htm [R=301,L]

Replace the broken pipe "¦" characters with solid pipes before use; Posting on this forum modifies the pipe characters.

Jim

4:43 pm on May 16, 2009 (gmt 0)

10+ Year Member



I contacted GD, and they replied :

"Unfortunately our hosting account does not have mod_alias, you may need to use mod_rewrite instead. "

ROptions +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteRule ^(offices¦contact_?us¦us¦apply¦[Oo]ur\ ?[Gg]roup¦pi)/ http://www.example.com/mix/contact.htm [R=301,L]

I used the code above but it did not work either...

Jim, may be there is some error?...

thank you

6:37 pm on May 16, 2009 (gmt 0)

10+ Year Member



I replaced brocken pipes too..
9:58 pm on May 16, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Is "ROptions" in your post above a typo in the post only, or is that in your "real" code? The correct directive is "Options" not "ROptions."

Are /offices, /contact_us and the rest being treated as subdirectories of the directory with this .htaccess file in it? If not, then you'll need to add any additional URL-path info needed to 'reach' these subdirectories.

BTW, it might be easier to simplify this rule and get it working with one "subdirectory" first. For example:


RewriteRule ^offices/ http://www.example.com/mix/contact.htm [R=301,L]

Jim
7:34 am on May 17, 2009 (gmt 0)

10+ Year Member



Thank you Jim,
It works!

you helped me so much...

good luck online and offline

 

Featured Threads

Hot Threads This Week

Hot Threads This Month