473,385 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Change url without actually changing it.

Markus
6,050 Expert 4TB
Is there a way i could get

http://somesite.com/viewer/someimage.jpg

to be recognised as

http://somesite.com/viewer/?id=someimage.jpg

I know i could rewrite the url with .htaccess but i don't want to change the lettering in the url.

The thing im trying to get at is;
how myspace do: myspace.com/username
but the 'username' isn't an actual directory.
I'm guesing it is read as myspace.com/?user=username

Hmm, anyone?

Thanks.
Nov 22 '07 #1
12 1764
Atli
5,058 Expert 4TB
Hi Markus.

Based on my brief experience with MySpace, I could very well believe that they actually create a directory for each user with a dynamically created index file.

Other than the UrlRewrite thing, I'm not sure how you could do what you are asking.

I'm very interested in seeing if anybody has a solution to this.
Nov 23 '07 #2
coffear
20
A normal mod rewrite rule is what you are looking for. As long as you do not specify the R flag in the rule the user will be unaware of anything happening.

For example something like this will work:-

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2.  
  3. RewriteRule ^viewer/([-_a-zA-Z0-9]+.jpg)$ /viewer/?id=$1 [L]
  4.  
Nov 23 '07 #3
Markus
6,050 Expert 4TB
A normal mod rewrite rule is what you are looking for. As long as you do not specify the R flag in the rule the user will be unaware of anything happening.

For example something like this will work:-

Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on
  2.  
  3. RewriteRule ^viewer/([-_a-zA-Z0-9]+.jpg)$ /viewer/?id=$1 [L]
  4.  
Thanks man! I had that exact(near enough) same rewrite just i had the [L] bit different!

Thanks again.

And @ atli:

if you go to myspace.com/username/index.php there isn't such a thing. I was told once it's done by virtual hosting? Not sure what that is, but y'know!

Thanks.x
Nov 23 '07 #4
Atli
5,058 Expert 4TB
And @ atli:

if you go to myspace.com/username/index.php there isn't such a thing. I was told once it's done by virtual hosting? Not sure what that is, but y'know!

Thanks.x
Myspace is built using M$ technology, ASP.Net, so it would probably be more like:
Expand|Select|Wrap|Line Numbers
  1. myspace.com/username/Default.aspx
I tried that but it gave me an error. Not 404 tho.
Nov 24 '07 #5
Markus
6,050 Expert 4TB
Myspace is built using M$ technology, ASP.Net, so it would probably be more like:
Expand|Select|Wrap|Line Numbers
  1. myspace.com/username/Default.aspx
I tried that but it gave me an error. Not 404 tho.
Truth be told, i don't care for MySpace - i was just intriguied by this, and now i may be able to build a networking site. (Not for general public use, just for a project)

:)
Nov 24 '07 #6
Markus
6,050 Expert 4TB
Expand|Select|Wrap|Line Numbers
  1. RewriteEngine on 
  2. RewriteRule ^viewer/([a-zA-Z0-1_-]+)\.([a-z]+)$ viewer/?ID=$1.$2 [L] 
  3.  
Is what i've came up with and t'is working! Thanks.
Nov 24 '07 #7
coffear
20
just 1 thing you have 0-1 in the regexp. You definitely only going to have 0 or 1 in the name?
Nov 24 '07 #8
Markus
6,050 Expert 4TB
just 1 thing you have 0-1 in the regexp. You definitely only going to have 0 or 1 in the name?

Oh! Thanks, i didn't see that - damn typos.
Nov 24 '07 #9
Atli
5,058 Expert 4TB
I'm not all that experienced with all this, but would it not be possible to replace "([a-zA-Z0-1_-]+)" with "(\w+)"?
Nov 25 '07 #10
Markus
6,050 Expert 4TB
I'm not all that experienced with all this, but would it not be possible to replace "([a-zA-Z0-1_-]+)" with "(\w+)"?
I was aware that there was some common expression that could take care of it, but i didn't know what it was.

Thanks Atli.
Nov 25 '07 #11
coffear
20
I'm not all that experienced with all this, but would it not be possible to replace "([a-zA-Z0-1_-]+)" with "(\w+)"?
Not quite \w is for the following range:-

a-zA-Z0-9_

so misses out the - but of course you could add that in. I personally however prefer whenever possible to use ranges so that it is easier to see what a regular expression does. Unless you specifically know what \w does you will have problems decoding the regexp whereas you have a better chance with actually using the ranges.
Nov 25 '07 #12
Markus
6,050 Expert 4TB
Not quite \w is for the following range:-

a-zA-Z0-9_

so misses out the - but of course you could add that in. I personally however prefer whenever possible to use ranges so that it is easier to see what a regular expression does. Unless you specifically know what \w does you will have problems decoding the regexp whereas you have a better chance with actually using the ranges.
Yeh, i was going to stick with

a-zA-Z0-9_-

For that very reason. Although knowing about \w is helpful for future reference :)
Nov 25 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Csaba2000 | last post by:
I have set onmousedown to change the cursor, but this setting is ignored (IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the mouse button is released. On Opera 7.01, the setting...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
5
by: Hank | last post by:
My Access 2000 code has been running for several years in our main plant. Now we need to install it, as a stand-along application, at remote sites, some of which are out of state. My problem is...
7
by: Peter Oliphant | last post by:
I use to make the statement that you could always replace any 'private' or 'public' access with 'public' and the code would still compile. This is no longer the case. It turns out that in /clr...
6
by: Michelle Stone | last post by:
Hi I am doing a bilingual .NET application for English/Arabic. On a web form, I have some edit boxes for data entry in Arabic and some for entry in English. Right now the user has to change his...
4
by: K.N.Ranjit | last post by:
Hi to all friends out there, I'm facing this problem for atleast 2 days but still have'nt yet solved my problem.I send the mail few days back (ie) in VB.net how to shift my form coordinates (ie)...
5
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I change the text in the url/location bar?...
45
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies...
11
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
2
by: Tamer | last post by:
Hi! Is there a way to change the protocoll type through Javascript without reloading (or making a request from the webserver) via Javascript? for example: http://mydomain.com...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.