Masking URL

  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post June 9th, 2011, 6:02 pm

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
http://www.schembrionics.com
The Ultimate Solutions Center
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 9th, 2011, 6:02 pm

  • WritingBadCode
  • Graduate
  • Graduate
  • User avatar
  • Joined: Apr 28, 2011
  • Posts: 214
  • Loc: Sweden
  • Status: Offline

Post June 10th, 2011, 4:29 am

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
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post June 10th, 2011, 10:11 am

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.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post June 10th, 2011, 11:37 am

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
http://www.schembrionics.com
The Ultimate Solutions Center
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post June 10th, 2011, 1:22 pm

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.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post June 10th, 2011, 3:03 pm

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
http://www.schembrionics.com
The Ultimate Solutions Center
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post June 10th, 2011, 3:13 pm

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?
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post June 10th, 2011, 4:06 pm

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
http://www.schembrionics.com
The Ultimate Solutions Center
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post June 10th, 2011, 5:08 pm

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.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post June 10th, 2011, 7:00 pm

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
http://www.schembrionics.com
The Ultimate Solutions Center
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post June 10th, 2011, 9:11 pm

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 :)
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Joined: Jun 21, 2006
  • Posts: 487
  • Loc: Conroe, Texas
  • Status: Offline

Post June 10th, 2011, 9:59 pm

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?
Thanks, Josh --DemonMaestro
www.LilNetwork.com
Fun Website www.ShoutsCloud.com
  • wpas
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jul 12, 2010
  • Posts: 214
  • Loc: Canada
  • Status: Offline

Post June 11th, 2011, 12:38 am

Hi demonmaestro

talking about making www.mydomain.com/whatIwant
from www.mydomain.com/whatever.html?main=hey
http://www.schembrionics.com
The Ultimate Solutions Center
  • demonmaestro
  • Gold Member
  • Gold Member
  • User avatar
  • Joined: Jun 21, 2006
  • Posts: 487
  • Loc: Conroe, Texas
  • Status: Offline

Post June 11th, 2011, 2:53 pm

Thanks, Josh --DemonMaestro
www.LilNetwork.com
Fun Website www.ShoutsCloud.com

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: No registered users and 112 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
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.