Jump to content

Recommended Posts

I am having a problem with my rewrite rules and there is no reason why it shouldn't display the right page as my other rewrite rules all work perfectly

 

I have a directory called guestbook which lists 10 entries at a time and is paged over so many pages.

 

I want the url to be from www.mydomain.com/guestbook/index.php?page=1 to www.mydomain.com/guestbook/1

 

As i say, i have used the same rewrite rules i have used for other pages and they all work

 

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^admin$ admin/ [R,L]
RewriteRule ^guestbook$ guestbook/ [R,L]

RewriteRule ^/?([a-zA-Z_]+)$ index.php?page=$1 [NC,L]
RewriteRule ^/?([a-zA-Z_]+)/([0-9]+)$ index.php?page=$1&pagenum=$2 [NC,L]
RewriteRule ^/?([a-zA-Z_]+)/([0-9]+)$ index.php?page=$1&id=$2 [NC,L]

RewriteRule ^/?gallery/jack$ index.php?page=jack_gallery [NC,L]
RewriteRule ^/?gallery/events$ index.php?page=events_gallery [NC,L]
RewriteRule ^/?gallery/honeylands$ index.php?page=honeylands_gallery [NC,L]

RewriteRule ^/?gallery/jack/image/([0-9]+)$ index.php?page=image&cat=jack&pagenum=$1 [NC,L]
RewriteRule ^/?gallery/events/image/([0-9]+)$ index.php?page=image&cat=events&pagenum=$1 [NC,L]
RewriteRule ^/?gallery/honeylands/image/([0-9]+)$ index.php?page=image&cat=honeylands&pagenum=$1 [NC,L]

RewriteRule ^/?archive/news$ index.php?page=archive_news [NC,L]
RewriteRule ^/?archive/news/([0-9]+)$ index.php?page=archive_news&pagenum=$1 [NC,L]

RewriteRule ^/?archive/honeylands_news$ index.php?page=archive_honeylands_news [NC,L]
RewriteRule ^/?archive/honeylands_news/([0-9]+)$ index.php?page=archive_honeylands_news&pagenum=$1 [NC,L]

RewriteRule ^/?archive/events$ index.php?page=archive_events [NC,L]
RewriteRule ^/?archive/events/([0-9]+)$ index.php?page=archive_events&pagenum=$1 [NC,L]

RewriteRule ^/?archive/articles$ index.php?page=archive_articles [NC,L]
RewriteRule ^/?archive/articles/([0-9]+)$ index.php?page=archive_articles&pagenum=$1 [NC,L]

RewriteRule ^/?admin/([a-zA-Z_]+)$ /admin/index.php?page=$1 [NC,L]
RewriteRule ^/?admin/([a-zA-Z_]+)/([0-9]+)$ /admin/index.php?page=$1&id=$2 [NC,L]

RewriteRule ^/?guestbook/([0-9]+)$ /guestbook/index.php?pagenum=$1 [NC,L]
RewriteRule ^/?guestbook/([a-zA-Z_]+)$ /guestbook/index.php?a=$1 [NC,L]
RewriteRule ^/?guestbook/([a-zA-Z_]+)/(0-9)$ /guestbook/index.php?a=$1&num=$2 [NC,L]

 

The problem is with the last 3 rewrite rules

 

here is some examples of my links

<a href="/guestbook/1"> from <a href="index.php?page=1">

 

<a href="/guestbook/viewIP/'.$num.'"> from <a href="index.php?a=viewIP&num='.$num.'">

 

What is really strange is that the second rewrite rule seems to work becuase I can have www.mydomain.com/guestbook/sign

 

 

Alright, I didn't play with mod_rewrite for quite some time but I wanna try..

RewriteRule ^guestbook/[(0-9)+]$ /guestbook/index.php?page=$1

 

The second one you said it's working so let's skip it.

 

For the third rewriterule I don't think it will works, because it's comflict with the 2nd rule, as you can see this,

 

index.php?a=$1

index.php?a=$1&num=$2

 

Correct me if I'm wrong.  :-X

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.