/    Sign up×
Community /Pin to ProfileBookmark

Friendly URL help

Hi all!

I have the link below which I created to test the functionality of the script I wrote. But because the rest of my site is setup with friendly or extensionless URLs, I want to do the same with this one:

[code=php]{
echo “<a href=’meta-paginated.php?page=$i’>$i</a> “;
}[/code]

This is the current rewrite rule I have in my .htaccess which works fine for normal links:

[code]RewriteRule ^(([^/]+/)*[^/.]+)$ index.php?page=$1 [L][/code]

So the question is,because I cant work it out.

  • 1.

    What would the regex be for this scenario?

  • 2.

    How would I need to change the link to work with the new rewrite rule and still select ?page 1,2,3,4,5, etc etc. The page ID is always a number?

  • Many thanks in advance. If you are kind enough to provide the solution would you be able to explain how you get there so I can learn and pass on my knowledge to other forum users in the future?

    Just to add:

    Okay,

    [B]This is the link in a raw format:[/B]

    meta-paginated.php?page=$i

    [B]This is what the URL looks like:[/B]

    [url]http://test.com/meta-paginated?page=2[/url]

    [B]This is the rule I think it should be but not completely sure:[/B]

    RewriteRule ^meta-paginated/(.*)/(.*)/$ /meta-paginated.php?$1=$2

    I am also not sure of the LINK construct that is why I havent listed it here.

    to post a comment
    PHP

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @GettingSmartApr 29.2012 — See http://www.edinteractive.co.uk/article/?id=48


    You need to put the following lines into your .htaccess file:

    RewriteEngine On

    RewriteRule /page/(.*)$ /page/page.php?id=$1

    This basically tells your website that any request for your page should be re-written. Doing this will mean that your addresses will become further simplified to the following:

    www.mysite.com/page/3
    [/QUOTE]


    Not sure if it works.. Simple google on terms 'htaccess friendly url'
    ×

    Success!

    Help @chrisguk spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...