Welcome to WebmasterWorld Guest from 54.196.104.66

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Url rewriting having ? sign

     
3:07 pm on Feb 10, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 15, 2010
posts: 126
votes: 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.
3:58 pm on Feb 10, 2011 (gmt 0)

Senior Member

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

joined:Nov 11, 2001
posts:5437
votes: 2


php?id [google.com]
4:08 pm on Feb 10, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 15, 2010
posts: 126
votes: 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
4:24 pm on Feb 10, 2011 (gmt 0)

Senior Member

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

joined:Nov 11, 2001
posts:5437
votes: 2


?param [google.com]
7:25 pm on Feb 10, 2011 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 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.
8:16 am on Feb 16, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 15, 2010
posts: 126
votes: 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]
9:04 am on Feb 16, 2011 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 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.
10:40 am on Feb 16, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 15, 2010
posts: 126
votes: 0


I added [QSA,R,L] but couldn't find any change.
8:24 pm on Feb 16, 2011 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 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.
3:21 am on Feb 18, 2011 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 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
2:07 pm on May 16, 2011 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 15, 2010
posts: 126
votes: 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.
2:34 pm on May 16, 2011 (gmt 0)

Senior Member

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

joined:July 3, 2002
posts:18903
votes: 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.