Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2013, 09:08 PM   PM User | #1
TylerB
New Coder

 
Join Date: Aug 2012
Location: Kalamazoo, MI
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
TylerB is an unknown quantity at this point
Post mod_rewrite pagination urls

I am rewriting all of the messy URL's on my site and I am having trouble rewriting URL's with pagination queries added to them.

I would like to do 1 rewrite rule for all pagination URL's (jobs and blogs) but as of right now I am only worried about getting it working.

The initial pagination query looks like this: blog.php?page=2 OR opportunities.php?page=2 I would LIKE them to look like this /blog/page/2 AND opportunities/page/2 but everything I've tried doesn't seem to work... The Rewrites WORK when I make them look like /blog-page/2 AND /opportunities-page/2 but I would like them to have a slash rather than a dash.

Here are ALL my current rewrites... the ones that need work are at the bottom. (blog pagination and opportunities pagination)

Code:
<IfModule mod_rewrite.c>
	RewriteEngine On

	# Full path to your site
	RewriteBase /

	# Rewrite all php files	   
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME}\.php -f
        RewriteRule ^(.*)$ $1.php
	
	# Rewrite the user profile pages
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^user/([a-zA-Z0-9_-]+)$ profile.php?user=$1
	RewriteRule ^user/([a-zA-Z0-9_-]+)/$ profile.php?user=$1
	
	# Rewrite the company profile pages
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^company/([a-zA-Z0-9_-]+)$ employer.php?user=$1
	RewriteRule ^company/([a-zA-Z0-9_-]+)/$ employer.php?user=$1
	
	# Rewrite the blog post pages
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^post/([a-zA-Z0-9_-]+)$ entry.php?id=$1
	RewriteRule ^post/([a-zA-Z0-9_-]+)/$ entry.php?id=$1
	
	# Rewrite the job listing pages
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteRule ^job/([a-zA-Z0-9_-]+)$ listing.php?id=$1
	RewriteRule ^job/([a-zA-Z0-9_-]+)/$ listing.php?id=$1
	
	# Rewrite the blog category queries
	RewriteRule ^/category/(.*)/?$ /$.php?cat=$1 [QSA]
	
	RewriteRule ^sort/(.*)/?$ /$.php?sort=$1 [QSA]
	
	# Rewrite blog pagination
	RewriteCond %{REQUEST_URI} !blog\.php [NC]
	RewriteRule ^blog/page/([0-9]+)$ blog.php?page=$1 
	RewriteRule ^blog/page/([0-9]+)/$ blog.php?page=$1	

	# Rewrite opportunity pagination
	RewriteCond %{REQUEST_URI} !opportunities\.php [NC]
	RewriteRule ^opportunities/page/([0-9]+)$ opportunities.php?page=$1 
	RewriteRule ^opportunities/page/([0-9]+)/$ opportunities.php?page=$1

</IfModule>
TylerB is offline   Reply With Quote
Reply

Bookmarks

Tags
htaccess, mod-rewrite, pagination, urls

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:54 PM.


Advertisement
Log in to turn off these ads.