how to mask URL with htaccess?
for example
i type in
www.myportal.com/cars/
no matter what links i navigate to within this site, i want the address bar in my browser to show just www.myportal.com/cars/
UNLESS
www.myportal.com/userpanel. i want the masking to stop when a l开发者_StackOverflow中文版ink pointing to userpanel is clicked.
This is not possible to do.
You can frame your site at yourportal.com/cars/ for the effect you want, but it's not something you can do with .htaccess.
You can't do this with a .htaccess
since by their very definiten URLs have to point to something and that doesn't change. You can't change a singly URL to mean whatever you want in that instant for a single session.
Mind you, it has been done before, it's called spoofing and is usually done for purposes of framing users by displaying a fraud site and showing a real URL in the address bar. Some etchniques might still be out there that work. I'd adivse against it, though.
Disclaimer: It's not me who suggests the following, it's my long-forgotten clone from the early 90s. He doesn't know any better about proper web standards and accessibility. Please refrain from using the following suggestion since it is, in fact, bad. Frames may have some uses on the web. This is not one of them and a pretty stupid thing to do. The accessibility and other drawbacks (loss of deep links) severely outweigh any potential benefits.
You may come closest with a frameset. You have a frameset which is at www.example.com/cars/
and just one frame in it which displays your site. Now every link you click will only change the location of the frame, not the frameset, meaning the URL in the address bar is still the same. You only need to add the target
attribute to links that go to www.example.com/userpanel
:
<a href="/userpanel" target="_top">Foo</a>
This will cause that URL to replace the old frameset.
You now don't have a way to link directly to a specific page, though.
精彩评论