lordphate Posted April 25, 2007 Share Posted April 25, 2007 Okay this may sound a little odd but here's what i'm wanting to find out: I want http://www.domain.com/index.php?page=classifieds to actually be http://classifieds.domain.com/ sounds easy right? WRONG, because i ALSO want all the classifieds to be http://classifieds.domain.com/nameofclassified INSTEAD OF http://www.domain.com/classifieds/nameofclassified ALL while keeping the url as classifieds.domain.com (or classifieds.domain.com/nameofclassified) Any help would be HIGHLY appreciated Link to comment https://forums.phpfreaks.com/topic/48685-yet-another-redirect-question/ Share on other sites More sharing options...
lachild Posted May 10, 2007 Share Posted May 10, 2007 This worked for me... RewriteEngine on RewriteCond %{HTTP_HOST} classifieds.domain.com RewriteRule ^$ index.php?page=classifieds [/code Link to comment https://forums.phpfreaks.com/topic/48685-yet-another-redirect-question/#findComment-249561 Share on other sites More sharing options...
lordphate Posted May 12, 2007 Author Share Posted May 12, 2007 This would work if of course i wanted only index.php?page=classifieds but i also need anything AFTER classifieds.domain.com/********** to associate as a folder Link to comment https://forums.phpfreaks.com/topic/48685-yet-another-redirect-question/#findComment-251022 Share on other sites More sharing options...
lachild Posted May 18, 2007 Share Posted May 18, 2007 I think you're making it too hard on yourself (I do this from time to time as well).. The rewrite code I gave you does just what you're asking. Let me break it down for you. First we add the rewrite condition: RewriteCond %{HTTP_HOST} classifieds.domain.com This tells mod_rewrite to check for your third level domain "classifieds" If it is then it moves on to test the next condition. RewriteRule ^$ index.php?page=classifieds Here we are telling mod_rewrite that if the url is blank (http://classifieds.domain.com/) re-write the url as index.php?page=classifieds if the URL isn't blank mod_rewrite will not touch it. That means that http://classifieds.domain.com/mydirectory will actually stay http://classifieds.domain.com/mydirectory. So as long as http://classifieds.domain.com/ pulls up the directory for http://www.domain.com/ by default, no further rewites are needed. However you could get as explicit as you want by simply adding additional rules like so: RewriteRule ^(.*).html$ index.php?page=$1{QUERY_STRING} [L,NS] The above would rewrite http://classifieds.domain.com/home.html to http://classifieds.domain.com/index.php?page=home Link to comment https://forums.phpfreaks.com/topic/48685-yet-another-redirect-question/#findComment-256547 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.