Forum Moderators: phranque

Message Too Old, No Replies

small mod rewrite problem

GET parameter is not working

         

TechMan

5:15 pm on Mar 11, 2010 (gmt 0)

10+ Year Member



I have the following code in my .htaccess file and it is working fine.

Options FollowSymLinks
RewriteEngine On
RewriteBase /beta

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([a-z0-9-]+)/([a-z0-9-]+)$ displaypage.php?page=$1&sub=$2 [NC,L]
RewriteRule ^([a-z0-9-]+)$ displaypage.php?page=$1 [NC,L]


So all my URL becomes without extension like this:

webmasterworld.com/news
webmasterworld.com/new/ok

But problem is I am unable to receive parameters using GET in URL.
For example if URL is webmasterworld.com/somenews?id=1&name=test

Then I am unable to GET parameters id and name on displaypage.php page. It is not receiving these parameters. What should I do?

Matthew1980

10:08 pm on Mar 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there techman!

RewriteRule ^id/(.*)/name/(.*)/index.html$ index.php?id=1&name=test$1 [nc]

Thats similar to what I have in my .htaccess file, though I could be wrong. This suffix's with "index.html", the idea is there anyway, have a play...

Try it anyway :)

Cheers,
MRb

g1smd

10:40 pm on Mar 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Whoa. Steady on there. Those multiple (.*) patterns are very very inefficient. Don't do that.

If you have changed the query string and need to add the original to the target, use the [QSA] flag.

Also, be aware that RewriteConds apply only to the single RewriteRule that follows it/them.

If you need RewriteConds for both rules, you need to duplicate those RewriteCond lines before each rule.

Be careful with the [NC] flag. It can promote Duplicate Content. If possible use all lower-case for all URLs. The danger is that /news and /NEWS and /News could all serve the same content - unless YOU take steps to stop that happening.