Skip to content

Instantly share code, notes, and snippets.

@BAHC
Last active May 31, 2019 01:55
Show Gist options
  • Save BAHC/212a0422c442e7db53fade9c2eec5fb2 to your computer and use it in GitHub Desktop.
Save BAHC/212a0422c442e7db53fade9c2eec5fb2 to your computer and use it in GitHub Desktop.
Redirect using mod_rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z]+)/([A-Za-z\+]+)/([0-9]+)/?$ tour/?id=$3&city=$2&country=$1 [NC]
RewriteRule ^([A-Za-z]+)/([A-Za-z\+]+)/?$ city/?city=$2&country=$1 [NC]
RewriteRule ^([A-Za-z^index]+)/?$ country/?country=$1 [NC]
RewriteRule . index.php [L]
</IfModule>
<h1>Index Route</h1>
<ul>
<li>Country/Town/123</li>
<li>Russia/Moscow</li>
<li>Russia</li>
</ul>
<p>$_GET:
<?php
var_dump($_GET);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment