homepage Welcome to WebmasterWorld Guest from 54.237.95.6
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe and Support WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
is this .htaccess correct?
Noximus




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

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]

 

jdMorgan




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

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

Noximus




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

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..

jdMorgan




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

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

Noximus




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

thank you jim

Noximus




msg:3914251
 10:25 am on May 15, 2009 (gmt 0)

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?

jdMorgan




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

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

Noximus




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

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

Noximus




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

I replaced brocken pipes too..

jdMorgan




msg:3915132
 9:58 pm on May 16, 2009 (gmt 0)

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

Noximus




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

Thank you Jim,
It works!

you helped me so much...

good luck online and offline

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved