Jump to content

[SOLVED] Drupal and .htaccess redirects


titel

Recommended Posts

Hi everybody,

 

I'm building a website for my NGO and I'm trying to create an redirect from some sub domains to the main website using .htaccess redirects.

 

What I've got already working is

RewriteCond %{HTTP_HOST} ^aiesec\.org.mk$ [NC]

RewriteRule .* http://www.aiesec.org.mk/ [L,R=301]

 

redirecting all from aiesec.org.mk to www.aiesec.org.mk

RewriteCond %{HTTP_HOST} ^skopje\.aiesec\.org.mk$ [NC]

RewriteRule .* http://www.aiesec.org.mk/skopje/ [L,R=301]

 

redirecting all from skopje.aiesec.org.mk to www.aiesec.org.mk/skopje

 

What I'm trying to achieve now, is to also keep into account what comes after the first part of the URL while redirecting. At the moment if you type skopje.aiesec.org.mk/whatever you'll be redirected to www.aiesec.org.mk/skopje, instead of www.aiesec.org.mk/skopje/whatever

 

Thank you in advanced,

tite

Link to comment
Share on other sites

I'm also looking for this functionality. I have a post (buried somewhere in) here at http://groups.drupal.org/node/2348 along the same lines. I've received some advice but it didn't work as planned. I'm confused as to why this should be so difficult - after all it seems a very reasonable request.

 

If someone does find a working method, perhaps they could cross-post to that thread too, please?

 

Thanks.

Link to comment
Share on other sites

Thanks a lot NikLP,

 

After a few days of searching on internet and posting on multiple forums without tangible results I finally made this work.

 

After reading the thread you indicated I finally managed to implement what I initially wanted using the following script.

 

 RewriteCond %{HTTP_HOST} ^aiesec\.org.mk$ [NC]
RewriteRule ^(.*)$ http://www.aiesec.org.mk/$1 [R=301,L]

 

Which redirects all the http://aiesec.org.mk including the URL parts afterwards to http://www.aiesec.org.mk

 

 RewriteCond %{HTTP_HOST} ^skopje\.aiesec\.org.mk$ [NC]
RewriteRule ^(.*)$ http://www.aiesec.org.mk/skopje/$1 [R=301,L]

 

Which redirects all the http://skopje.aiesec.org.mk including the URL parts afterwards to http://www.aiesec.org.mk/skopje

 

Hope you'll manage to fix it as well,

titel

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.