Hi I have a site where I'd like to convert the first subfolder into a parameter (from a set list of subfolders), so
http://localhost/mysite/folder1/dosomething.php
is displayed as shown above, but to PHP it looks like:
... localhost/mysite/dosomething.php?organisation=folder1
I only need to do this on certain folders (i.e. not ... localhost/mysite/admin/ for example) and I need to take into account the fact that there may or may not already be parameters appended to the URL
I'm creating a site for multiple organisations to use, and based on the organisation, colours etc in the site will need to be different, but each organisation will be using the same pages, and the client wants the organisation shortcode in the URL. I thought the best way to do this would be with mod_rewrite.
I've tried:
rewriterule ^folder1/(.*) $1&organisation=folder1 [NC]
but this doesnt work or handle the fact there might already be parameters attached to the URL. Can anyone suggest a way to do this?
Kind regards and many thanks
Based on your feedback:
Hmm I can't get this to work. In .htaccess I have Options +FollowSymLinks RewriteEngine on RewriteRule ^folder1/(.*) $1&organisation=folder1 [NC,QSA]
If I browse ... server/sitename/folder1/destination.php I get a page not found error, and the htaccess debug log says:
(3) [perdir /var/www/sitename/] add path info postfix: /var/www/sitename/folder1 -> /var/www/sitename/folder1/destination.php (3) [perdir /var/www/sitename/] strip per-dir prefix: /var/www/sitename/folder1/destination.php -> folder1/destination.php (3) [perdir /var/www/sitename/] applying pattern '^folder1/(.*)' to uri 'folder1/destination.php' (2) [perdir /var/www/sitename/] rewrite 'folder1/destination.php' -> 'destination.php&organisation=folder1' (3) [perdir /var/www/sitename/] add per-dir prefix: destination.php&organisation=folder1 -> /var/www/sitename/destination.php&organisation=folder1 (2) [perdir /var/www/sitename/] strip document_root prefix: /var/www/sitename/destination.php&organisation=folder1 -> /sitename/destination.php&organisation=folder1 (1) [perdir /var/www/sitename/] internal redirect with /sitename/destination.php&organisation=folder1 [INTERNAL REDIRECT] (3) [perdir /var/www/sitename/] strip per-dir prefix: /var/www/sitename/destination.php&organisation=folder1 -> destination.php&organisation=folder1 (3) [perdir /var/www/sitename/] applying pattern '^folder1/(.*)' to uri 'destination.php&organisation=folder1' (1) [perdir /var/www/sitename/] pass through /var/www/sitename/destination.php&organisation=folder1