Page 1 of 1

HTACCESS: can I set one /mobile URL to one page?

Posted: Mon Jun 17, 2013 10:05 am
by simonmlewis
I need to point a particular shorturl to a particular page.

Most pages like domain.com/newproducts, go to index.php?page=<title>
But I want to do a specific one:
domain.com/mobile, to go to index_ip.php?page=ihome.

I thought this would work, but it doesn't:

Code: Select all

RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L]
RewriteRule ^mobile/ index_ip.php?page=ihome [L]
Doesn't work the other way around either.

Re: HTACCESS: can I set one /mobile URL to one page?

Posted: Mon Jun 17, 2013 10:10 am
by AbraCadaver
Without testing it, I would say that the first rule matches and then it terminates never getting to the next rule. Try:
[text]RewriteRule ^mobile/ index_ip.php?page=ihome [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L][/text]

Re: HTACCESS: can I set one /mobile URL to one page?

Posted: Mon Jun 17, 2013 10:14 am
by AbraCadaver
And maybe the / is not in the URL at that position? You might try:
[text]RewriteRule ^/mobile
or
RewriteRule ^mobile[/text]

Re: HTACCESS: can I set one /mobile URL to one page?

Posted: Mon Jun 17, 2013 10:15 am
by simonmlewis
Doesn't work.
This script rejects it as an unknown page and takes me to my error page:

Code: Select all

  function getPage()
  {
  $thispage="includes/".$_GET['page'].".inc";

  if (file_exists($thispage)) 
  {
   include $thispage;
  } 
  else 
  {
  echo "<meta http-equiv='Refresh' content='0 ;URL=/error'>";
  }
  } 
HTACCESS needs to see it as a page.

Re: HTACCESS: can I set one /mobile URL to one page?

Posted: Mon Jun 17, 2013 10:21 am
by simonmlewis

Code: Select all

RewriteRule ^/mobile index_ip.php?page=ihome [L]
RewriteRule ^/mobile/ index_ip.php?page=ihome [L]
Neither of these work.
They both just go to my error page.
Also, I do have this right at the top of the HTACCESS.

Re: HTACCESS: can I set one /mobile URL to one page?

Posted: Mon Jun 17, 2013 2:33 pm
by requinix
.htaccess and mod_rewrite don't "see" anything as "pages". All they do is change the URL.

If your index_ip.php does not accept page=ihome then you have to fix it so it does. Is the page it should be executing named includes/ihome.inc?