简体   繁体   中英

Rewrite url in htaccess php

I want to rewrite url as following.

This is url : http://www.xyzdomain.com/?page=9

i want it like this : http://www.xyzdomain.com/9

Add this to the htaccess file in your document root:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+\?page=([0-9]+)
RewriteRule ^ /%1? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ /?page=$1 [L,QSA]

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