1

I have created a subdomain for my website (fr.mohamedkadri.com) and after 24 hours it became active but it redirects to the subfolder that I poited to (mohamedkadri.com/fr)

Is there a problem? why the subdomain redirects to the subfolder?

here is my .htaccess:

SetEnv PHP_VER 5

RewriteEngine On

RewriteCond %{HTTP_HOST} !^mohamedkadri.com$ [NC]
RewriteRule ^(.*)$ http://mohamedkadri.com/$1 [L,R=301]
1
  • so the problem is in the htaccess! but how to make it enforce the url without www and keep other subdomains? Mar 10, 2011 at 1:40

3 Answers 3

1
  1. You could add a more rewrite conditions

    RewriteCond %{HTTP_HOST} !^mohamedkadri.com$ [NC]

    RewriteCond %{HTTP_HOST} !^fr.mohamedkadri.com$ [NC]

    RewriteRule ^(.*)$ http://mohamedkadri.com/$1 [L,R=301]

  2. You could setup apache virtual hosts, so each domain would have its own configuration.

2
  • Thanks for your answer, I think its a good solution but I got a simpler way. Mar 10, 2011 at 1:51
  • The answers do the same thing in different ways: Your's leaves everything alone but www.mohamedkadri.com. Mine redirects everything to mohamedkadri.com except for fr.mohamedkadri.com. Depending on your goal, either one could be best.
    – Steven
    Mar 10, 2011 at 1:53
0

afaik subdomains are stored in subfolders (e.g. apache). as long as you can reach your target via the intended fr.mohamedkadri.com/and/more/URL where is the problem?

Edit0: Imho you have to use rewrite rules (apache mod_rewrite) in your .htaccess file in the folder named according to your subdomain.

2
  • the problem is that when I write fr.mohamedkadri.com I get mohamedkadri.com/fr/, the subfolder that the subdomain "fr" is pointing to Mar 10, 2011 at 1:14
  • so a larger url must be like fr.mohamedkadri.com/anything-else and not mohamedkadri.com/fr/anyting-else Mar 10, 2011 at 1:16
0

Ok I got the point!

I eidted my htaccess file:

RewriteCond %{HTTP_HOST} !^mohamedkadri.com$ [NC] RewriteRule ^(.*)$

to

RewriteCond %{HTTP_HOST} www.mohamedkadri.com$ [NC] RewriteRule ^(.*)$

So I got the www removed and other subdomains kept as is!

Thanks for your replies ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.