homepage Welcome to WebmasterWorld Guest from 54.211.73.232
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

    
Url rewriting having ? sign
fahad direct



 
Msg#: 4265171 posted 3:07 pm on Feb 10, 2011 (gmt 0)

I am tying to add ? in the end of my rewritten url as

[site-domain.com...]
to
[site-domain.com...]

I have tried it with:
RewriteRule ^(.*)\.htm([\?A-Za-z]*)$ /index.php?param1=$1&param2=$2 [L]

?param=foo i want in param2 though it works if i do without ? sign and doesn't work with ? sign. Guide me please.

 

wilderness

WebmasterWorld Senior Member wilderness us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4265171 posted 3:58 pm on Feb 10, 2011 (gmt 0)

php?id [google.com]

fahad direct



 
Msg#: 4265171 posted 4:08 pm on Feb 10, 2011 (gmt 0)

Thanks for the search link but what i am looking for couldn't find. I have already rewritten my urls and i want to add further ? sign after my rewritten url like mydomain/rewrittenpage.html?param=foo

wilderness

WebmasterWorld Senior Member wilderness us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4265171 posted 4:24 pm on Feb 10, 2011 (gmt 0)

?param [google.com]

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4265171 posted 7:25 pm on Feb 10, 2011 (gmt 0)

Use the
[QSA,L] flag to re-append the original query string data.

RewriteRule ^([^.]+)\.htm$ /index.php?param1=$1 [QSA,L]

Use a more efficient pattern than
(.*) here too.
fahad direct



 
Msg#: 4265171 posted 8:16 am on Feb 16, 2011 (gmt 0)

Hi,
Thanks for the replies.
Am i still doing wrong as nothing getting in param1 and here is the code:

RewriteRule ^([^.]+)\.htm$ /folder_name/index.php?lastitle=$1 [L]
RewriteRule ^([^.]+)\.htm$ /folder_name/index.php?param1=$1 [QSA,L]

Also tried:
RewriteRule ^([^.]+)\.htm?$ /folder_name/index.php?param1=$1 [QSA,L]

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4265171 posted 9:04 am on Feb 16, 2011 (gmt 0)

Temporarily add the R flag so that you can see what is being appended. It will show in the browser URL bar. Use the "Live HTTP Headers" extension for Firefox to examine in more detail.

The second code example looks correct, but only if the code is in the .htaccess file found in the root of the site.

fahad direct



 
Msg#: 4265171 posted 10:40 am on Feb 16, 2011 (gmt 0)

I added [QSA,R,L] but couldn't find any change.

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4265171 posted 8:24 pm on Feb 16, 2011 (gmt 0)

The R flag means the request will redirect to a new URL. You don't actually want a redirect to a new URL, but having the redirect there (temporarily) allows you to see what that URL would be, what path is requested and what parameters are attached.

Look at that URL in the URL bar of the browser. Does that URL contain all the right path and parameter data? It doesn't matter if content is served or not, you just look at the URL itself to see if it is malformed.

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4265171 posted 3:21 am on Feb 18, 2011 (gmt 0)

Just guessing based on your earlier code:

RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule ^([^.]+)\.htm$ /folder_name/index.php?lastitle=$1&param2=%1 [L]

This takes a client request for /xyz.htm?abc and rewrites it to /folder_name/index.php?title=xyz&param2=abc

Jim

fahad direct



 
Msg#: 4265171 posted 2:07 pm on May 16, 2011 (gmt 0)

[site-domain.com...] works quite fine now with ? sign but when i try without ? sign it doesn't work like:

[site-domain.com...]

Any help please.

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4265171 posted 2:34 pm on May 16, 2011 (gmt 0)

When you temporarily added the R to "see" the path and parameters, you should have seen:

/index.php?param1=value&add

rather the required value of:

/index.php?param1=value&param2=add

and that should have told you that I misread the question when I supplied some example code.



In the current code, the
(.+) insists there is a parameter present for the following Rewrite to happen.

Change the
.+ to .* if the parameter is optional.

Use example.com to stop forum auto-linking.

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