Forum Moderators: phranque

Message Too Old, No Replies

rewrite id as sub-domain?

.htaccess rewrite as sub-domain

         

roymj88

7:17 am on Sep 23, 2011 (gmt 0)

10+ Year Member



Hi Guys,

Is it possible to re-write the htaccess in such a way that it can show sub-domain in the browser url?.. Like wordpress.com

Say the incoming url is domain.com?id=10.

So can it be re-written in such a way that it shows something.domain.com where something is fetched from database according to the id that is obtained through the url.

Please let me know if someone has already cracked this because this opens up a whole new level for my use of htaccess. I'm sure many will be hoping for similar thing.



Thanks

Roy M J
[itzmeroymj.wordpress.com...]

g1smd

7:26 am on Sep 23, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



URLs are defined in links.

The "incoming URL" is defined by the URL that you place in the <a href="something"> tags on the pages of your site.

Mod_rewrite operates only after that link is clicked. It runs through all of the rules in .htaccess looking for one that matches the current URL request.

If one matches, mod_rewrite then acts to redirect that request to a different URL or rewrite it to fetch the content from some non-default location inside the server.

You are in control of what the URLs for a site "look like". You control that by what you place in the links on the pages. After the link is clicked, you then rewrite those incoming requests to actually fetch/serve the content from wherever it really is inside the server.

Mod_rewrite does not "make" URLs, nor can it change the links on your pages.

roymj88

7:49 am on Sep 23, 2011 (gmt 0)

10+ Year Member



Hi Thanks for replying,

I have a project which needs a website builder like word press but with lesser options. I first started with thought of creating folders for each registrations and then use ht access to rewrite to show as sub domain or so. But then when users flow in the server space and all will be a problem.

Hence i thought of making everything dynamic and then use ht access to re-write as sub domain. Ive found that with something called wildcard sub-domain option it is possible to create dynamic sub-domains or rewrite using htaccess as sub domain.

Let me know if this is possible or any other method to create sub-domains dynamically.


Thanks

Roy M J

g1smd

7:52 am on Sep 23, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, it is possible and there are several hundred previous threads with example code.