My mobile site (tiny custom CMS inspired by wordpress) has a homepage, blog page, a news page, an about page and a contact page where ./blog
./news
./about
and ./contact
are actual folders. Homepage, Blog and News are paginated. About and Contact are single pages, no pagination.
I need htaccess rewrite rules to do the following (A) and (B). I have only made progress with (A), and the htaccess file is in the site root.
(A)
-
m.website.com/index.php?page=1
re-writes tom.website.com
-
m.website.com/index.php?page=2
re-writes tom.website.com/page/2
etc -
m.website.com/blog/index.php?page=1
rewrites tom.website.com/blog
-
m.website.com/blog/index.php?page=2
re-writes tom.website.com/blog/page/2
etc -
m.website.com/news/index.php?page=1
rewrites tom.website.com/news
-
m.website.com/news/index.php?page=2
re-writes tom.website.com/news/page/2
etc
Problems:
Below is what I'm using for the above, but I only got it working for the homepage for now. I don't know how to combine the rules to include blog and news pages too. Also, it duplicates my links because m.website.com
and m.website.com/page/1
are both in use. I need to get rid of /page/1
everywhere. Pagination should start only from page 2. I tried to get rid of it using the RedirectMatch but it didn't work so I commented it out.
RewriteEngine On
RewriteBase /
RewriteRule ^page/(.*) index.php?page=$1 [NC]
#RedirectMatch 301 ^/page/1/$ http://m.website.com/
(B)
- I already have a permalink.php file which accepts pretty URLs and returns their postIDs
- The read-more link for each article on the home, blog or news page will have the format
http://m.website.com/2012/03/the-post-title
- When clicked, the htaccess will query permalink.php with the string
/2012/03/the-post-title
to get the postID, then openshttp://m.website.com/article.php?id=postID
but the address in the address bar will behttp://m.website.com/2012/03/the-post-title
and this shows the article in full, be it home page, blog page or news page.
Problem: I have been searching and I'm not exactly sure how to go about (B) above but I know it's possible. In the end, all rules for A and B will be in the same htaccess file in the site root.
Thanks