Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mod_rewrite [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
veilig
Apprentice
Apprentice


Joined: 11 May 2005
Posts: 153

PostPosted: Sat Jan 03, 2009 4:58 am    Post subject: mod_rewrite [SOLVED] Reply with quote

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
View user's profile Send private message
jmz2
Guru
Guru


Joined: 13 Jan 2004
Posts: 421
Location: Finland

PostPosted: Sun Jan 04, 2009 8:57 am    Post subject: Re: mod_rewrite Reply with quote

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
View user's profile Send private message
tuam
l33t
l33t


Joined: 04 May 2004
Posts: 765
Location: CGN, Germany

PostPosted: Sun Jan 04, 2009 2:27 pm    Post subject: Re: mod_rewrite Reply with quote

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
View user's profile Send private message
jmz2
Guru
Guru


Joined: 13 Jan 2004
Posts: 421
Location: Finland

PostPosted: Sun Jan 04, 2009 2:31 pm    Post subject: Re: mod_rewrite Reply with quote

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
View user's profile Send private message
veilig
Apprentice
Apprentice


Joined: 11 May 2005
Posts: 153

PostPosted: Sun Jan 04, 2009 4:38 pm    Post subject: Reply with quote

figured it out:

had to adjust the directory settings for my virtual host
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum