View previous topic :: View next topic |
Author |
Message |
veilig Apprentice
Joined: 11 May 2005 Posts: 153
|
Posted: Sat Jan 03, 2009 4:58 am Post subject: mod_rewrite [SOLVED] |
|
|
I'm trying to get my rewrite rules to work but I'm running into a bit of a snag and stuck on what to do.
I have my mod_rewrite loaded when I check phpinfo().
in my .htaccess file I can do something simple like
Code: | RewriteRule ^page1.html page2.html |
and page2.html gets loaded when I visit page1.html
however, if I get any more elaborate, ie:
Code: | RewriteRule ^page/([0-9]*)/$ page.php?pageid=$1 |
it looks like page.php is being called but my parameters aren't being passed in.
anyone have a clue on what I can look at to find out whats causing this?
Last edited by veilig on Sun Jan 04, 2009 4:38 pm; edited 1 time in total |
|
Back to top |
|
|
jmz2 Guru
Joined: 13 Jan 2004 Posts: 421 Location: Finland
|
Posted: Sun Jan 04, 2009 8:57 am Post subject: Re: mod_rewrite |
|
|
veilig wrote: | however, if I get any more elaborate, ie:
Code: | RewriteRule ^page/([0-9]*)/$ page.php?pageid=$1 |
it looks like page.php is being called but my parameters aren't being passed in.
anyone have a clue on what I can look at to find out whats causing this? |
Do you get the pageid parameter in $_GET['pageid']? If you do not get the pageid parameter, then there's something wrong with your PHP.
If you mean other query parameters (ie. things after a question mark in the URL), you need to modify your rewrite rule: Code: | RewriteRule ^page/(\d+)/$ page.php?page=$1 [QSA] |
|
|
Back to top |
|
|
tuam l33t
Joined: 04 May 2004 Posts: 765 Location: CGN, Germany
|
Posted: Sun Jan 04, 2009 2:27 pm Post subject: Re: mod_rewrite |
|
|
Code: | RewriteRule ^page/([0-9]*)/$ page.php?pageid=$1 |
I haven't tried mod_rewrite, but I'm not sure your regex needs those slashes? I would expect something like
Code: | RewriteRule ^page([1-90]+)\.html$ page.php?pageid=$1 |
FF,
Daniel _________________ Logic clearly dictates that the needs of the many outweigh the needs of the few. - Spock
The needs of the one outweigh the needs of the many. - Kirk
I refuse to let arithmetic decide questions like that. - Picard |
|
Back to top |
|
|
jmz2 Guru
Joined: 13 Jan 2004 Posts: 421 Location: Finland
|
Posted: Sun Jan 04, 2009 2:31 pm Post subject: Re: mod_rewrite |
|
|
tuam wrote: | Code: | RewriteRule ^page/([0-9]*)/$ page.php?pageid=$1 |
I haven't tried mod_rewrite, but I'm not sure your regex needs those slashes? I would expect something like
Code: | RewriteRule ^page([1-90]+)\.html$ page.php?pageid=$1 |
FF,
Daniel |
RewriteRule ^page/([0-9]*)/$ matches URIs like /page/88/
Note the trailing slash.
RewriteRule ^page([1-90]+)\.html$ matches URIs like /page88.html
How your URIs look like is a matter of style. |
|
Back to top |
|
|
veilig Apprentice
Joined: 11 May 2005 Posts: 153
|
Posted: Sun Jan 04, 2009 4:38 pm Post subject: |
|
|
figured it out:
had to adjust the directory settings for my virtual host |
|
Back to top |
|
|
|