简体   繁体   中英

.htaccess URL rewriting not working on pagination?

I have this following url localhost/test/index.php?page=1 And i want it to be 'index.php/page/1' so far I have this :

RewriteEngine On
RewriteRule    ^page/([0-9]+)/?$    index.php?page=$1    [NC,L]

But it's not working .Any suggestion what am i doing wrong ?

Try with this

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

If you set it correct then URL like this http://localhost/test/page/1 should work

Try this one

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

The url will be

localhost/test/index.php/page/123

If you want the url looks like

localhost/test/index.php/page/123/

change you rule into this one

RewriteEngine on
RewriteRule  ^(.*)/page/([0-9]+)/$ /index.php?page=$2 [NC,L]
 RewriteRule ^index.php\/page\/(.*?)\/?$ index.php?page=$1 [NC]

The above code should solve your probleem. But you may want to read up on mod_url_rewrite

See https://www.sitepoint.com/guide-url-rewriting for more info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM