Masking URL

  • wpas
  • Proficient
  • Proficient
  • User avatar
  • Posts: 322
  • Loc: Canada

Post 3+ Months Ago

Hi All

I have the following:

real URL: http://www.mydomain.com/folderA/folderB/file.php

I want to use a masked URL to get to the same file as in the real URL:

http://www.mydomain.com/file.php

When I enter the masked URL into my browser, I should be taken to the file as shown in the real URL. Also, the browser must still show the masked URL.

I want to do this with htaccess but have had no luck.
I have searched and everything I found does not work.

Would someone be able to give me the mod_rewrite script so that I can make this work

Thanks
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • WritingBadCode
  • Graduate
  • Graduate
  • User avatar
  • Posts: 214
  • Loc: Sweden

Post 3+ Months Ago

Quote:
real URL: http://www.mydomain.com/folderA/folderB/file.php

I want to use a masked URL to get to the same file as in the real URL:

http://www.mydomain.com/file.php


I don't get it, is both those "real urls"? :|
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Put this in your .htaccess file under your RewriteEngine On directive:

Code: [ Select ]
RewriteRule ^file\.php$ /folderA/folderB/file.php [L]


I believe that should do the trick.
  • wpas
  • Proficient
  • Proficient
  • User avatar
  • Posts: 322
  • Loc: Canada

Post 3+ Months Ago

Thanks for your reply

It worked but it did not display any of the images that were supposed to be on the page. The images are in the same directory as the file
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

You would have to write RewriteRules for each and every image, or in your code that is loading make sure you use absolute URLs for the images so that it knows the real location on the server for those images. That rewrite rule above is only for "file.php", nothing else.
  • wpas
  • Proficient
  • Proficient
  • User avatar
  • Posts: 322
  • Loc: Canada

Post 3+ Months Ago

I put in the absolute URLs to the images and that did the trick

thanks

If I may, I would like to ask one more question.

In one of my web pages, someone needs to enter a passcode in order to continue.
Once the passcode is submitted, they go to the next page.

The URL in the browser address bar would be

www.mydomain.com/file.html?pass=123456

Is it possible to do a Rewrite that would only show the following in the browser:

www.mydomain.com/file.html

Thanks
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Do they fill out a form to goto the next page? If so instead of making the for a GET request, make it a POST request. GET requests are shown in the browser URL, while POST requests are not. So for example a GET request would be:

HTML Code: [ Select ]
<form name="myForm" action="file.php" method="get">


while a POST request would be:

HTML Code: [ Select ]
<form name="myForm" action="file.php" method="post">


Is that what you might be looking for?
  • wpas
  • Proficient
  • Proficient
  • User avatar
  • Posts: 322
  • Loc: Canada

Post 3+ Months Ago

Hi

I have a joomla 1.5 cms website

I have a plugin that asks for the passcode.
It basically intercepts the Registration form and asks for the passcode before allowing registration.

The friendly URL is created by the sh404SEF component I have installed.

The forms are thus automatically created for me
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I am not sure how that plugin works. Depending on exactly what you need it may require you to contact that developer of the plugin, or modify the plugin directly yourself so that the URLs are friendly. If you decide to modify it yourself and if you have any questions with anything specific like above, I am sure I could be of some help.
  • wpas
  • Proficient
  • Proficient
  • User avatar
  • Posts: 322
  • Loc: Canada

Post 3+ Months Ago

Thanks for the reply

What I was hoping was that I could somehow use htaccess to mask the query string.

I heard this was possible but I am not sure
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I believe what you are referring to is the other way around though. For instance you could go:

Code: [ Select ]
RewriteRule ^file\.php$ /folderA/folderB/file.php?var=value&var2=value2 [QSA,L]


So you are passing variables along to the script via the rewrite rule itself, the QSA modifier allows you to append to the query string in case a query string already existed as well. So for instance if someone on your server requested:

/file.php?myvar=myvalue

Then it would really call:

/folderA/folderB/file.php?myvar=myvalue&var=value&var2=value2

Without the QSA modifier then it would really call:

/folderA/folderB/file.php?var=value&var2=value2

With the QSA part aside, I believe this is still the opposite way around from what you are saying. What you are saying is if someone goes to:

/file.php?myvar=myvalue

then make it so the query string disappears from the browser's address bar. The only way you could do that would be at that point to redirect via a 301 or 302 redirect. The proper way would be to change the script itself so that it directs the user to the right link in the first place so that you do not have to go through a redirect.

I hope that makes sense, and hopefully I am understanding what you are saying correctly :)
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

wpas wrote:
Thanks for the reply

What I was hoping was that I could somehow use htaccess to mask the query string.

I heard this was possible but I am not sure



are you talking about making www.mydomain.com/whatIwant
from www.mydomain.com/whatever.php?main=hey or www.mydomain.com/whatever/this/whatever/hey/index.html?

or taking a long url and making it www.mydomain.com/whatIwant and show the whatIwant at all times in the url bar?
  • wpas
  • Proficient
  • Proficient
  • User avatar
  • Posts: 322
  • Loc: Canada

Post 3+ Months Ago

Hi demonmaestro

talking about making www.mydomain.com/whatIwant
from www.mydomain.com/whatever.html?main=hey
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Posts: 674
  • Loc: Conroe, Texas

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 57 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.