Forum Moderators: phranque
RewriteRule ^uk/([^/]*)$ ./?currency=3 [L,NC]
I'm trying to create a rule that will rewrite URLs ending with "?currency=3" to a "/uk/" directory.The code you supplied actually accepts a URL request like
example.com/uk/<something> and rewrites it to fetch content from a script at /<indexfile>?currency=3 inside the server - and that difference is crucial. www.example.com/uk/<anything> will be accepted by the rule and content served. The NC flag further adds to the woe, by allowing aNyCase on those infinite URL variations. <something> part of the www.example.com/<something> URL request varies, and you would want to serve different content for each variation?
Additionally, the rule allows infinite Duplicate Content because any URL request matching www.example.com/uk/<anything> will be accepted by the rule and content served. The NC flag further adds to the woe, by allowing aNyCase on those infinite URL variations.
1. domain.com/?currency=3 to domain.com/uk/
2. domain.com/computers.php?currency=3 to domain.com/uk/computers.php
3. domain.com/laptop/?currency=3 to domain.com/uk/laptop/
4. domain.com/laptop/hp.php?currency=3 to domain.com/uk/laptop/hp.php
I want to create a rewrite rule, that accepts a URL request forNotice that one is a URL including domain name and the other is a server-internal filepath.and fetches content from the internal pathexample.com/uk/computersinside the server./computers.php?currency=3
RewriteRule ^uk/([a-z0-9\-]+)$ /$1.php?currency=3 [L] RewriteRule ^uk/([^/.]+)$ /$1.php?currency=3 [L] href="/uk/<something>" from the pages of your site. example.com/computer/hp (contains slash, does not end with slash) style URLs - which will rewrite to the named file, and the other for the example.com/computer/ (ends with slash) URLs - which will rewrite to the index.php file. The URL needs to contain "identifying features" so that the correct rule matches the incoming request. The rules must not match requests for robots.txt, image files, CSS or JS files, etc.
RewriteRule ^uk/([^/]*)$ ./$1?currency=3 [L]