Hi Dklynn,
Thanks for your help.
Note #5: Since URLs can't have spaces (except as %20), use underlines or hyphens to replace them. If you ABSOLUTELY have to use spaces (%20) in your URIs, you can include them in your regex within a range definition as \{space}, i.e., ([a-zA-Z\ ]+). However, this is NOT advised.
Note #6: If you are converting to/from a database field which does contain spaces, you should convert the spaces to some other character. Using PHP, you can use
$state = str_replace ( ' ', '_', $state );
I've tried a few different variations but my syntax still does not work. On my make-model.php page I'm replacing the space with a _ and it's not working. What do you think I'm doing wrong?
Thanks for your help.
make-model.php syntax
PHP Code:
$state = str_replace (' ','_', $state);
$city = str_replace (' ','_', $city);
$model = str_replace (' ','_', $model);
Code:
RewriteEngine On
RewriteRule ^([_a-zA-Z_]+)$ state.php?state=$1 [L]
RewriteRule ^([_a-zA-Z_]+)/([_a-zA-Z_]+)$ city.php?state=$1&city=$2 [L]
# RewriteRule ^([a-zA-Z_]+)/([a-zA-Z_]+)/([_a-zA-Z_]+)/([_a-zA-Z_]+)/([_a-zA-Z_]+)$ make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/([^/]*)/([^/]*)/([^/]*)$ /make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
# RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
Code:
RewriteEngine On
RewriteRule ^([_a-zA-Z_]+)$ state.php?state=$1 [L]
RewriteRule ^([_a-zA-Z_]+)/([_a-zA-Z_]+)$ city.php?state=$1&city=$2 [L]
RewriteRule ^([_a-zA-Z]+)/([_a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z]+)/([_a-zA-Z_]+)$ make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
# RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/([^/]*)/([^/]*)/([^/]*)$ /make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
# RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
Code:
RewriteEngine On
RewriteRule ^([_a-zA-Z_]+)$ state.php?state=$1 [L]
RewriteRule ^([_a-zA-Z_]+)/([_a-zA-Z_]+)$ city.php?state=$1&city=$2 [L]
# RewriteRule ^([_a-zA-Z_]+)/([_a-zA-Z_]+)/([_a-zA-Z_]+)/([_a-zA-Z_]+)/([_a-zA-Z_]+)$ make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/([^/]*)/([^/]*)/([^/]*)$ /make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
# RewriteRule ^([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /make-model.php?state=$1&city=$2&year=$3&make=$4&model=$5 [L]
Bookmarks