3
votes

I have a PHP website,

e.g. http://www.test.com/rewrite-test/s/z2SZhBL

This was previously on Apache which had a rewrite rule to trap the "z2SZhBL" using the $_GET['id'].

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ /index.php?id=$1 [L]

I need to move this website onto IIS and I need to get the URL rewrite rule working. I have tried these examples.

http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

So in the folder "rewrite-test" I have an index.php which is echoing out the $_GET variables and there are no get variables coming back they are all empty.

I can get the variables using this workaround.

$params = explode( "/", $_SERVER['HTTP_X_ORIGINAL_URL'] );
print_r($params);

Is this best solution?

1
your just asking an opinion?davejal
Well I am wondering if this is the correct way to retrieve the variables after they are rewritten, it feel like what I have done might be a hack/workaround should the variable not be obtainable via the $_GET, perhaps what I have done is correct.davesherlock
Just import your .htaccess file to your URL Rewriter. There is a small link to this wizard. All the same rules and techniques can be used. IIS will capture and rewrite it to the index.php?id=$1 so you can continue to use $_GET.Twisty

1 Answers

0
votes

IIS Manager has a good Import Rules tool. See full walk through here: http://www.iis.net/learn/extensions/url-rewrite-module/importing-apache-modrewrite-rules

  1. Open URL Rewrite
  2. In Actions Pane, click Import Rules
  3. Browse to your .htaccess file (Or Copy/Paste them in)
  4. Review the Converted Rules
  5. Rename the rule as desired
  6. Click Apply Link to save the converted rules