Why is a / required?

 
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting
View previous topic :: View next topic  
Author Message
cenocre
-


Joined: 12 Mar 2007
Posts: 47

PostPosted: Tue Mar 10, 2009 9:06 pm    Post subject: Why is a / required? Reply with quote

In doing the following change:

http://domain.com/this/index.html --> http://domain.com/that/index.html

This works:

Quote:
Virtual path: ^/this(.*)$
internal redirection to: /that$1
append query string


This does not:

Quote:
Virtual path: ^this(.*)$
internal redirection to: that$1
append query string


The only difference is the leading "/". Why should this matter at all? I have found that this also occurs in all other rewrites. What gives?
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 881
Location: Michigan, USA

PostPosted: Wed Mar 11, 2009 3:10 am    Post subject: Reply with quote

The short answer: that's just how HTTP works.

When you make a request for http://aprelium.com/index.html , it looks like this to the web server:

Code:
GET /index.html HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: www.aprelium.com
Connection: Keep-Alive
Cookie: phpbb2mysql_data=a%3A2%3A%7Bs%3A11%3A%22autologinid%22%3Bs%3A0%3A%22%22%3Bs%3A6%3A%22userid%22%3Bi%3A-1%3B%7D; _csuid=498f917c28e37df5


These were the HTTP headers my browser sent. Below are the response HTTP headers generated by Aprelium's web server.

Code:
HTTP/1.1 200 OK
Content-Type: text/html
Last-Modified: Fri, 20 Feb 2009 12:17:14 GMT
Vary: User-Agent
Content-Encoding: gzip
Connection: Keep-Alive
Keep-Alive: timeout=200000, max=10
Transfer-Encoding: Chunked
Date: Wed, 11 Mar 2009 02:06:11 GMT
Server: Abyss/2.6.0.0-X2-Linux AbyssLib/2.6.0.0


You'll notice I asked aprelium.com for the page /index.html. All HTTP requests begin with a slash. Even if I just ask for http://aprelium.com , it will ask for this:
GET / HTTP/1.1 (which is asking for the default page).

FYI, your regex said the request must begin with "this" or "that". Requests always begin with a slash, so nothing in your example would match. The caret (^) means "begins with" in regex.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
cenocre
-


Joined: 12 Mar 2007
Posts: 47

PostPosted: Wed Mar 11, 2009 9:22 pm    Post subject: Reply with quote

So, if ^ means beginswith is there something that means contains?
Back to top View user's profile Send private message
pkSML
-


Joined: 29 May 2006
Posts: 881
Location: Michigan, USA

PostPosted: Thu Mar 12, 2009 1:35 am    Post subject: Reply with quote

cenocre wrote:
So, if ^ means beginswith is there something that means contains?

Nothing.

By default, it's looking to see if the requested URL (URI actually) matches (contains) the regex. The caret is a modifier. BTW, the dollar sign means ends with.

So in your example that didn't work, just take out the caret and it would work as you expected.
BUT, if you just have this or that in the regex, it will match more than you potentially realize. That's why it's good practice to get specific as possible with regex.
"this" will match:
thispage
whatpageisthis
/whatever/secret/this/page etc...
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> URL Rewriting All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB phpBB Group