1
`example.com/recent/index.php?page=2`  i want to like this -> `example.com/recent/page/2`

.htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteBase /recent/

RewriteRule ^([^/]+/([0-9]+)/?$ index.php?page=$2 [L,QSA]

index.php?page=2

<?php
echo $_GET['page'];
?>

how to create for that htaccess file. how to it from last url example.com/recent/page/2

2 Answers 2

1

We can rewrite urls using .htaccess files. But before writing something in .htaccess files we need to verify which kind of server we are using. Here in the case you may use either an apache server or a Nginx server. You can easily check by just adding a

<?php phpinfo(); ?>

in a php page.

Case 1 : Apache Server:

Ensure that mod_rewrite module enabled in apache server. This can be identified by checking phpinfo included page.

Common methods used for url rewriting is as follows

RewriteEngine

This is mandatory for any apache server. This is used to enable the rewriting engine. In some cases it should be on by default.So ensure that following code must be mandatory in top of your htaccess file

RewriteEngine On

RewriteRule

in some cases you may have only few pages and you can specify each page in your website in .htaccess file. In such case you can use these kind of rewriting For example

RewriteRule ^article/used/to/be/here.php$ /article/now/lives/here/ [R=301,L]

Suppose you have to rewrite url like these

http://en.wikipedia.org/wiki/url_rewriting

You should write something like these on your .htaccess file

RewriteEngine On
RewriteRule   ^wiki/(.+)$   w/index.php?title=$1   [L]

But actual implementation of the page will be like these

http://en.wikipedia.org/w/index.php?title=url_rewriting

RewriteCond

This can be used for rewriting certain url with respect to some conditions. Suppose you need to add or remove www with your website name and on certain condition redirect to certain page like "url not available or error message "

Example :

RewriteCond %{HTTP_REFERER} !^http://(www.)?example.com/.*$ [NC] 

You can further refer here

Introduction to url rewriting

Rewrite with examples

Case 2 : nginx Server

Enable module HttpRewriteModule on your nginx server Use location to rewrite you urls as per nginx settings

Example

    location / {
    root   /path/to/drupal;
    index  index.php index.html;
 
    try_files $uri $uri/ @rewrite;
}
 
location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
}
Sign up to request clarification or add additional context in comments.

3 Comments

i dont know how fix it. from thi link how to get last number http://www.col3negmovie.com/recent/page/2 this pagenation.
and i want to display this page col3negmovie.com/recent/index.php
if u can plz help me for this post stackoverflow.com/questions/23002755/…
0

Try this:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /recent/

RewriteRule ^([^/]+)/([0-9]+)/?$ index.php?$1=$2 [L,QSA]

1 Comment

if u can plz help me this post stackoverflow.com/questions/23002755/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.