homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
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

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

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


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)

php?id [google.com]

fahad direct

 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


 4:24 pm on Feb 10, 2011 (gmt 0)

?param [google.com]


 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

 8:16 am on Feb 16, 2011 (gmt 0)

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)

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

 10:40 am on Feb 16, 2011 (gmt 0)

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


 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.


 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


fahad direct

 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:


Any help please.


 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:


rather the required value of:


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