Search code examples
phpjavascriptflash.htaccess

How mod rewrite can impact on PHP, JS or AS3 variables and paths


Mod rewrite changes the look of URLs but does it matter for server-side scripts (PHP)?
Does it change the $_GET[] in PHP? Will sth like:

if ( strpos($pulledId,':') > 0 ) { $pulledId = substr($pulledId,0,strpos($pulledId,':')); }

work, when there is no "id=" in diplayed URL? How about JavaScript? How about Flash? Can mod rewrite be a problem when loading external files from server ?

AS3 or JS are client-side scripts. So I assume they get URL as it is in a browser, but PHP, JAVA are server-side, so they should get URL which haven't been processed by mod rewrite.


Solution

  • mod_rewrite can perform two types of redirections:

    • Internal redirections: RewriteRule ^catalogue/product-(\d+)/?$ products.php?product_id=$1 [L]
    • HTTP redirections: RewriteRule ^foo?$ http://example.com/bar [L]

    Additionally, it can strip off the original query string or append it to the resulting URL (if you use the [QSA] flag).

    PHP basically sees the same as the browser unless there's an internal redirection, in which case it sees the final URL and (optionally) the original query string.