Jump to content

Recommended Posts

Well, I think the simplest method is to just send all requests to the respective page, and let PHP to the parsing of the URI. You'll have to come up with a regex for that.

 

In PHP you could do something like

<?php
$uri = $_SERVER['REQUEST_URI'];
$params = explode("/", $uri);

You now have all the parts of the URI in an array. It would look something like this:

array {
            [0] => 'http:'
            [1] => ''
            [2] => 'example.com'
            [3] => 'CountryName'
            [4] => 'CityName'
}

 

You can see how with the knowledge that REQUEST_URI will always contain what the user actually requested, and not the real path to the script, you can parse the URI and get the information you want out of it.

Link to comment
https://forums.phpfreaks.com/topic/196551-mod-rewrite-and-php/#findComment-1031963
Share on other sites

RewriteRule ^(.*)/(.*)/?$ page.php?CountryID=$1&CityName=$2 [L]

 

Should work. But may not yeild the exact results you want, as anything even say example.com/sub/realdir/ will get redirected as well.

cool this works

i still have the CityID as a number

so the url looks like this

amsterdam-tourist-sites/1.html

regarding seo is this a good move

keeping the number?

Link to comment
https://forums.phpfreaks.com/topic/196551-mod-rewrite-and-php/#findComment-1031994
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.