Hi I've got a site where Let me convert the very first subfolder right into a parameter (from the set listing of subfolders), so
is displayed as proven above, but to PHP it appears like:
I only have to do that on certain folders (i.e. not ... localhost/mysite/admin/ for instance) and I have to consider the truth that there might be parameters appended towards the URL
I am developing a site for multiple organisations to make use of, and in line with the organisation, colours etc within the site will have to be different, but each organisation is going to be utilizing the same pages, and also the client wants the organisation shortcode within the URL. I figured the easiest method to do this is with mod_rewrite.
I have attempted:
rewriterule ^folder1/(.*) $1&organisation=folder1 [NC]
but this does not work or handle the very fact there may be parameters connected to the URL. Can anybody suggest a method to do that?
Xox and thank you
According to your feedback:
Hmm I can not get this work. Inshtaccess I've Options +FollowSymLinks RewriteEngine on RewriteRule ^folder1/(.*) $1&organisation=folder1 [NC,QSA]
Basically browse ... server/sitename/folder1/destination.php I recieve a webpage not found error, and also the htaccess debug log states:
(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/] using 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/] using pattern '^folder1/(.*)' to uri 'destination.php&organisation=folder1' (1) [perdir /var/www/sitename/] go through /var/www/sitename/destination.php&organisation=folder1
To append parameters towards the query string (rather than changing them) make use of the QSA flag:
RewriteRule ^folder1/(.*) $1&organisation=folder1 [NC,QSA]
"This flag forces the rewrite engine to append a question string area of the substitution string towards the existing string, rather than changing it. Make use of this when you wish to include more data towards the query string using a rewrite rule."
RewriteRule ^folder1/(.*)?(.*) $1?organisation=folder1&$2 [NC] RewriteRule ^folder1/(.*) $1?organisation=folder1 [NC]
I suspect somebody that is a little niftier with RegExs could mix these into one rule tho
Also make certain you've mod rewrite switched on by getting
over the rewrite rules inside your .htaccess