Jump to content

2 really simple mod rewrite questions


AdRock

Recommended Posts

I have this rewrite rule which reads [url=http://www.jackgodfrey.org.uk/news/1/2]www.jackgodfrey.org.uk/news/1/2[/url]

[b]RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/([0-9]+)/?$ index.php?page=$1&limit=$2&pagenum=$3 [L][/b]

How would I rewrite that to read [url=http://www.jackgodfrey.org.uk/news/2]www.jackgodfrey.org.uk/news/2[/url] so it takes the /1/ out as that never changes.  It's only a limit to how many records are listed per page

The second question is this:

I have 4 pages names jack1, jack2, jack3 and jack4

How would i create a rule to read like this [url=http://www.jackgodfrey.org.uk/jack/1]www.jackgodfrey.org.uk/jack/1[/url] etc?
Link to comment
https://forums.phpfreaks.com/topic/18357-2-really-simple-mod-rewrite-questions/
Share on other sites

Do you wantr to get rid of the limit parameter completly if so use this:
[code]RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/?$ index.php?page=$1&pagenum=$2 [L][/code]

For your secound question, I'm not sure but prehaps this:
[code]RewriteRule ^jack/([0-9]+)/$ jack$1.php[/code]
by file name you mean jackx.php, x being a number?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.