blunerve Posted January 25, 2007 Share Posted January 25, 2007 I'm working on a site where we need to rewrite www.example.com/win.html to show only www.example.com I have tried the mod_rewrite rule and the deflector.map in the .htaccess file. These take the entire site out of commission and returns 500 Internal Browser Errors. I'm not sure exactly how to write the mod_rewrite to correspond with what I need. Please help!!!! Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/ Share on other sites More sharing options...
steviewdr Posted January 25, 2007 Share Posted January 25, 2007 You could put a meta-refresh tag on www.example.com/win.html and for it to go to www.example.com/index.htmlYou could also symlink win.html to index.html. So on linux:ln -s /home/account/public_html/win.html /home/account/public_html/index.htmlI dont know can this be done in a htaccess. It probably can be done in the main apache config.Best of Luck with it,-steve Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169122 Share on other sites More sharing options...
blunerve Posted January 25, 2007 Author Share Posted January 25, 2007 I don't need it to redirect to index.html, just mask the fact they're looking at the page win.html. Would the meta tags accomplish this?If not, would it be easier to mask a sub-domain (sub.example.com) to show only the actual domain (example.com) in the address bar?Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169129 Share on other sites More sharing options...
steviewdr Posted January 25, 2007 Share Posted January 25, 2007 Oh - well meta tags will not hide the URL.Here is an idea for you to try in a htaccess file:DirectoryIndex win.htmlIf that doesnt work ->So - if ppl go to www.example.comyou want them to see www.example.com/win.html ??rename win.html to index.html?Im still not quite sure what you want to do.-steve Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169140 Share on other sites More sharing options...
cmgmyr Posted January 25, 2007 Share Posted January 25, 2007 I don't think this can be done with htaccess.The best thing to do is to make two frames. One 1 pixel in size, the rest 100% in size. Then load the page into the big frame and the URL in the addressbar will never change again.Hope this helps,-Chris Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169145 Share on other sites More sharing options...
blunerve Posted January 25, 2007 Author Share Posted January 25, 2007 When I send someone to www.example.com/win.html, I do not want them to see win.html so they don't know the file name and be able to go back to that site or send it to someone else. So when they click the link to www.example.com/win.html, they're taken to that page, but they should only be able to see www.example.com in the address bar. Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169147 Share on other sites More sharing options...
blunerve Posted January 25, 2007 Author Share Posted January 25, 2007 The DirectoryIndex in the .htaccess file did not work. I don't think the frames will either only because the only link to win.html will be through a different site completely. Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169165 Share on other sites More sharing options...
steviewdr Posted January 25, 2007 Share Posted January 25, 2007 So - I still need a little clarification:You provide the link "www.example.com/win.html" on someone elses website. When a person clicks on that link, you want them brought to that page (win.html), but JUST for the ADDRESS BAR to READ www.example.com ??Will you have a www.example.com/win2.html link, which you want disguised also??So basically - when people are surfing YOUR website - you ONLY want www.example.com showing???Frames or Iframes sounds about right to me.Also - you could script up an index.php file and serve out pages like:www.example.com/?1 (where 1 points to win.html)www.example.com/?2 (where 2 points to win2.html)-steve Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169220 Share on other sites More sharing options...
blunerve Posted January 25, 2007 Author Share Posted January 25, 2007 Right, I only want the address bar to show www.example.com no matter what page they are on in the site.If I did the PHP www.example.com/?1 how would I set that up in index.php? Could I do ?3 for other PHP pages on the site as well? Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169226 Share on other sites More sharing options...
steviewdr Posted January 25, 2007 Share Posted January 25, 2007 [quote author=blunerve link=topic=124008.msg513453#msg513453 date=1169755442]Right, I only want the address bar to show www.example.com no matter what page they are on in the site.[/quote]OK - I know what you are getting at. Its termed hijacking the Address Bar!!! Well there might be a javascript hack to get it working - but its far from ideal.[quote]If I did the PHP www.example.com/?1 how would I set that up in index.php? Could I do ?3 for other PHP pages on the site as well?[/quote]This is the best route to go down.Basically you setup a index.php file which serves out all your site content, and with apache mod_rewrite you can rewrite the URL from www.example.com/win.html to www.example.com/?1The ?/1 is also index.php?1The ?1 is a $_GET[] function, which takes in a number, and based on a list of webpages you have, pick out win.html, and pass it through.This might work:<?phpecho $_GET['pg'];?>And if you call the above page with (or work via mod_rewrite) via www.example.com/?pg=1you should be able to work it.-steve Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169238 Share on other sites More sharing options...
blunerve Posted January 25, 2007 Author Share Posted January 25, 2007 Would anyone be able to go back to www.example.com/?1 Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169249 Share on other sites More sharing options...
steviewdr Posted January 26, 2007 Share Posted January 26, 2007 YES - if you scripted the file, you would be able to access both:www.example.com/?pg=1www.example.com/win.htmlBUT - with an apache rewrite - ONLY - www.example.com/?pg=1 will show up in the address bar.ACTUALLY - what am I thinking - apache mod_rewrite will do ALL OF THIS FOR YOU.Apache will/can rewrite www.example.com/win.html to show as www.example.com/1/Read up on apache mod_rewrite.-steve Quote Link to comment https://forums.phpfreaks.com/topic/35686-i-need-help-with-the-htaccess-file-to-rewrite-url/#findComment-169560 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.