Forum Moderators: phranque
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]
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
Jim
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
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?
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]
Jim
"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
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]