Hi All,

I currently have an .htaccess set up to rewrite to a single URL.

at the minute it is for places. so mysite.com/region/town will rewrite to places.php

i now need to add another, this time for skill i.e. mysite.com/construction/bricklayer and i want it to redirect to skills.php

i have included the re-write below. Any help would be appreciated.

# category two or more levels down

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)/$ places.php?place=$3&rr=9 [nc,L,qsa]

# category one level down

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9_-]+)/$ places.php?place=$1&rr=13 [nc,L,qsa]

Recommended Answers

All 3 Replies

How will you determine whether a link is region/town or construction/bricklayer ? Both rewrites are two levels, and are built using identical expressions. My guess is that you can only solve this by using a PHP file to determine which one it is and do the correct redirect.

thats the magic question. I have no idea. At present this works for places only.

If you want to use a PHP file, then you need some way to determine which of the two it is (database perhaps).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.