开发者

need help in creating rewrite rule

开发者 https://www.devze.com 2023-03-17 09:39 出处:网络
i have been trying to create a rule for dynamic sub-domains and tried many rules given by other users. I am able to use dynamic sub-domains and they are working fine now.

i have been trying to create a rule for dynamic sub-domains and tried many rules given by other users. I am able to use dynamic sub-domains and they are working fine now.

My sub-domain structure is sub1.sub2.domain.com

Now i want that when a user goes to sub1.sub2.domain.com then the default page must be code.php and not index.php

Als开发者_Go百科o in address bar only sub1.sub2.domain.com should be visible and not sub1.sub2.domain.com/code.php

Also i have to use two level sub-domains not single sub.domain.com

I just need help in creating the rewrite rule which displays code.php when user accesses sub1.sub2.domain.com

Thank You


You can try this in .htaccess

# Provide Specific Index Page (Set the default handler)
DirectoryIndex code.php

Edit: In your index.php page, before your HTML try something like this:

if($_SERVER['SERVER_NAME'] == 'example.com' || $_SERVER['SERVER_NAME'] == 'www.example.com'){
     header('Location: /index.php');
}else{ 
     header('Location: /code.php');
}

This should look at the server name, including sub-domain and work out what to use from there from memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消