4

I would like it to show the url /index.php?page=somePage&id=someID&siteAddress=someAddress as /someAddress/?page=somePage&id=someID.

How can I use the rewrite rule for this?

  • Where is `someAddress` coming from? Is that the value of the `siteAddress` query string parameter? – Jon Lin Oct 16 '12 at 03:11
  • Fixed to be clearer wording. siteAddress should be equal to someAddress, the value supplied between the two forward slashes. – user1748794 Oct 16 '12 at 03:14

1 Answers1

0

To internally rewrite /someAddress to /index.php:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^page=([^&]+)&id=([^&]+)$
RewriteRule ^/?([^/]+)/$ /index.php?page=%1%id=%2&siteAddress=$1 [L]

To externally redirect /index.php to /someAddress:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?page=([^&]+)&id=([^&]+)&siteAddress=(^[&\ ]+)
RewriteRule ^ /%3/?page=%1&id=%2 [L,R=301]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220
  • I would like to internally rewrite it, so I added that code to .htaccess. But the site did not display the resultant page. The site is http://public.forumzbb.com/test/?page=register&id=null. What I should be seeing on the page is is http://public.forumzbb.com/index.php?page=register&id=null&siteAddress=test. Yes, it should show up as a simple "Site Not Setup." text. Thank you for your help :) – user1748794 Oct 16 '12 at 03:31
  • @user1748794 Are you placing these rules at the top of the htaccess file in your document root? Are you sure mod_rewrite is turned on? Do you have `AllowOverride All` set in your vhost/server config? – Jon Lin Oct 16 '12 at 03:33
  • Oops, thank you. Solved now, just forgot to put 'RewriteEngine On' at the top of the file as well. Thank you again :) – user1748794 Oct 16 '12 at 03:38