homepage Welcome to WebmasterWorld Guest from 204.236.255.69
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirect URLs with Question Marks
troyid




msg:4345905
 1:15 pm on Jul 31, 2011 (gmt 0)

I want to redirect a subdomain and all urls to my root domain. e.g. cgi.example.com to www.example.com

I currently have this.

RedirectMatch 301 (.*) http://www.example.com/

My problem is that I have a number of URLs with question marks.

e.g. [cgi.example.com...]

These urls are redirecting to http://www.example.com/?ringid=test;siteid=vincentvds instead of what I want which is http://www.example.com

 

lucy24




msg:4345933
 3:52 pm on Jul 31, 2011 (gmt 0)

I don't think you can do it with mod_alias ("Redirect" as opposed to "Rewrite"). If you change it to a rewrite [httpd.apache.org], just stick a naked ? at the end and it will strip away any existing query strings.

g1smd




msg:4345938
 4:00 pm on Jul 31, 2011 (gmt 0)

RewriteRule ^requested-path http://www.example.com/new-path? [R=301,L]

The trailing question mark clears the query string.

srinuv




msg:4355756
 1:51 am on Aug 27, 2011 (gmt 0)

Hi,

I am new to Apache config..I have similar problem but in a different way..I have site urls like
[url]www.example.com/SampleSite/Which Terminal?[/url]

I have rewrite rule like this

RewriteRule ^/(.*)$ www.exmaple.com/SampleSite/$1 [L,PT]

what is happening is..apache not sending "?" character to server..so server not able to resolve the URL..

I have verified apache rewrite logs..below part is coming

split uri=www.example.com/SampleSite/Which Terminal? -> uri=www.example.com/SampleSite/Which Terminal, args=<none>


How can I make sure that "?" will also be passed to server without truncating from apache? please suggest me..

Thank you.

lucy24




msg:4355779
 2:57 am on Aug 27, 2011 (gmt 0)

Oh, ###. Do you mean that your url contains a literal question mark? It's not the beginning of a query string, but part of the actual filename?

:: staggering off to lie down with cold compress on forehead ::

srinuv




msg:4355807
 5:08 am on Aug 27, 2011 (gmt 0)

Yes Lucy, my website has few URLs like that. And my client testing by creating different URLs for testing my application..like SampleSite/test-?-@ like this..if "?" appears..apache splitting URL into two parts and sending second argument as parameter...

How can I tell Apache don't do this? please help me on that.

g1smd




msg:4355826
 7:03 am on Aug 27, 2011 (gmt 0)

.if "?" appears..apache splitting URL into two parts and sending second argument as parameter
Apache is working exactly as it should.

The question mark is a "reserved" character in the HTTP specification. It is the path to query string delimiter.

Also reserved are colon and slash. Don't break the HTTP specs.

srinuv




msg:4355827
 7:25 am on Aug 27, 2011 (gmt 0)

Actually the request coming in UTF-8 encoded format like /SampleSite/Which Terminal%3F..but still apache considering it as "?" and splitting it..can't we use "?" in url other than query parameters?
Please let me know your comments.

g1smd




msg:4355894
 5:47 pm on Aug 27, 2011 (gmt 0)

You are not free to put any character you like in a URL.

Certain characters are reserved for specific purposes.

lucy24




msg:4355938
 9:20 pm on Aug 27, 2011 (gmt 0)

It occurs to me that you (or your bosses) may be confusing the file name with the page title. The filename is seen only by computers (and by people who study the exact content of the browser's address bar). The title is the text that appears at the top of the window. It's basically just a special category of content and can be almost anything, provided it isn't too long and you've dealt with file encoding.

Something like <title = "Which Terminal?"> is perfectly fine ... so long as the file it's attached to is called, say, which_terminal.html

srinuv




msg:4356156
 3:24 am on Aug 29, 2011 (gmt 0)

Thank you for your suggestions.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved