Forum Moderators: phranque
a) Welcome Page (Displays a A-Z list of website prefixes)
b) Displays listing of websites for the selected prefix (E.g "S")
c) Displays details of selected website (E.g "Simon's website")
So...
index.php ---> /
index.php?list=s ---> /s/
index.php?list=s&site=simon---> /s/simonswebsite/
Can somone please advise how I can do this, the problem is that the site name could also be the same as the prefix (E.g index.php?list=s&site=s).
My current code...
----------------------
RewriteEngine on
RewriteRule ^index\.html$ /index.php [L]
RewriteRule ^([a-z]{1})/?$ /index.php?list=$1 [L]
----------------------
Thanks all, hope someone can help.
The least painful solution is to disallow the use of single-character names for anything except your 'prefix directory section' URLs. Or you could tag the prefix directory section URLs with a unique URL-path prefix or extension.
mod_rewrite isn't magic; It depends on matching information in the HTTP request from the client (e.g. browser) to decide whether and what action to take. So you have to provide sufficient information in the URL or query string to make this decision.
Jim
www.mydomain.com/list_s/site_example/
which I need to point to:
index.php?list=s&site=example
Do I have a seperate .htaccess line for re-writting 'list_s' and another line for re-writting 'site_example' or do I do this on one line?
Static case:
RewriteRule ^list_s/site_example/ /index.php?list=s&site=example [L]
RewriteRule ^([^_]+)_([a-z])/([^_]+)_([^/]+)/ /index.php?$1=$2&$3=$4 [L]
Jim
I'm not sure what I'm doing wrong but it's probably something stupid.
Here is my .htaccess in full:
------------------------------------------------------
RewriteEngine on
## "index.html" requests "index.php"
RewriteRule ^index\.html$ /index.php [L]
## "/list_other/" requests "/index.php?list=other"
RewriteRule ^([^_]+)_([^_]+)/ /index.php?$1=$2 [L]
## "/list_other/site_example/" requests "/index.php?list=other&site=example"
RewriteRule ^([^_]+)_([^_]+)/([^_]+)_([^_]+)/ /index.php?$1=$2&$3=$4 [L]
------------------------------------------------------
/ works fine (directs to /index.php)
/list_other/ works fine (directs to /?list=other)
/list_other/site_example/ doesn't work, my code still can't find the value of $site