Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7725959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:05:21+00:00 2026-06-01T05:05:21+00:00

My mobile site (tiny custom CMS inspired by wordpress) has a homepage, blog page,

  • 0

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 to m.website.com
  • m.website.com/index.php?page=2 re-writes to m.website.com/page/2 etc
  • m.website.com/blog/index.php?page=1 rewrites to m.website.com/blog
  • m.website.com/blog/index.php?page=2 re-writes to m.website.com/blog/page/2 etc
  • m.website.com/news/index.php?page=1 rewrites to m.website.com/news
  • m.website.com/news/index.php?page=2 re-writes to m.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 opens http://m.website.com/article.php?id=postID but the address in the address bar will be http://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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:05:22+00:00Added an answer on June 1, 2026 at 5:05 am

    This should do the trick for you. It looks like you have done most of it so there isn’t muc to do.

    RewriteEngine On  
    RewriteBase /
    
    # you do not need a rewrite for the root as you should have index.php
    # as your default document and page 1 as your default page
    
    RewriteRule ^page/1/?$                    / [NC,L,R=301]
    RewriteRule ^page/(\d+)/?$                index.php?page=$1 [NC,L]
    
    # you do not need a rewrite for blog as you should have index.php as your
    # default document and page 1 as your default page
    
    # you do not need a rewrite for news as you should have index.php as your
    # default document and page 1 as your default page
    
    RewriteRule ^(blog|news)/page/1/?$        $1 [NC,L,R=301]
    RewriteRule ^(blog|news)/page/(\d+)/?$    $1/index.php?page=$2 [NC,L]
    
    ######################################################################
    ################## ADD YOUR PERMALINK.PHP CODE HERE ##################
    ######################################################################
    

    UPDATE
    To effectively turn /2012/03/the-post-title into a postID you need to be able to ask your database to do that for you as it is the only thing that knows the answer. So you can either use a RewriteMap http://httpd.apache.org/docs/2.3/rewrite/rewritemap.html#dbd I have never done this myself and I would advise against it. Not because I know there is a problem with it I just have a bad feeling about it.

    The alternative and one I would champion is to just do something like this:-

    RewriteRule ^(\d{4})/(\d{2})/([^/]+))/?$     article.php?postIdentifier=$1/$2/$3 [L]
    

    Then in article.php hit the database and use the information in the postIdentifier to get the correct article.

    Make sense?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a page for a small mobile site that has an image that
Our jQTouch mobile site has a News & Events sections. Because of technical limitations
I'm looking to build a mobile version of a WordPress site and have most
My site is optimized for desktop and mobile. Most of my post has youtube
Okay im creating a mobile site and I have a page of images and
I am developing a mobile site which has multiple divs. I have validator set
So I'm working on a mobile site that has some videos on it. I
I'm developing a mobile site using Zend framework, and the site has two possible
I have a mobile site and I'd like to redirect users to the domain.mobi
I'm hitting a mobile site from a new Blackberry and the user agent is:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.