Forum Moderators: phranque
mydomain.com/1/, mydomain.com/1/2/ and mydomain.com/1/2/3. In these url's is 1 the branch within the user can search, 2 respresentates the city and 3 defines the company name.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^(style|media)(/.*)?$ - [L]
RewriteRule index\.* index.php [L,QSA]
RewriteRule ^([^/]*)/([^/]*)/$ branch.php?branch=$1&city=$2 [L,QSA]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ company.php?branch=$1&city=$2&company=$3 [L,QSA]
RewriteRule ^([^/]*)/([^/]*)$ branch.php?branch=$1&city=$2 [L,QSA]
RewriteRule ^([^/][a-zA-Z0-9-]+)$ branch.php?branch=$1 [L,QSA]
</IfModule>
mydomain.com or mydomain.com/1. The adresses mydomain.com/1/ and further redirects to the right filename (branch.php or company.php), but keeps searching for stylesheet.css in mydomain.com/1/style/ (or mydomain.com/1/2/style and so on). I know there are a lot of these questions on this site, and I tried many of their solutions, but none of them really does what I want. domain.com/1/ rewrites to index.php?1=1 and domain.com/1/a/b rewrites to index.php?1=1&2=a&3=b. In index.php I will lookup which page I have to include then). RewriteRule ^(style|media)(/.*)?$ - [L] RewriteRule ^([^/]*)/([^/]*)/$ branch.php?branch=$1&city=$2 [L,QSA]
...
RewriteRule ^([^/]*)/([^/]*)$ branch.php?branch=$1&city=$2 [L,QSA] RewriteRule index\.* index.php [L,QSA] RewriteRule ^(style|media)(/.*)?$ - [L] RewriteRule ^(style|media) [L] ^([^/]*)/([^/]*)/$ matches a request for example.com/// - change the * to + here and in the other rules. ^([^/][a-zA-Z0-9-]+)$ simplifies to ^([a-zA-Z0-9-]+)$ unless you're saying that the first character of the request can be something other than a-zA-Z0-9- ^([^/]*)/([^/]*)$ matches example.com/images/image.png. You probably want to add a "." in final grouping using ^([^/]+)/([^/.]+)$ instead (also * -> + as mentioned before). Make the same changes to the "3-deep" rule too.