Jump to content

I need help with the .htaccess file to rewrite URL


blunerve

Recommended Posts

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!!!!
Link to comment
Share on other sites

You could put a meta-refresh tag on www.example.com/win.html and for it to go to www.example.com/index.html

You could also symlink win.html to index.html. So on linux:

ln -s /home/account/public_html/win.html /home/account/public_html/index.html

I 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
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

Oh - well meta tags will not hide the URL.

Here is an idea for you to try in a htaccess file:
DirectoryIndex win.html

If that doesnt work ->
So - if ppl go to www.example.com
you 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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[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/?1

The ?/1 is also index.php?1

The ?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:

<?php
echo $_GET['pg'];
?>

And if you call the above page with (or work via mod_rewrite) via www.example.com/?pg=1
you should be able to work it.

-steve
Link to comment
Share on other sites

YES - if you scripted the file, you would be able to access both:
www.example.com/?pg=1
www.example.com/win.html

BUT - 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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.