开发者

.htaccess query string to folder format

开发者 https://www.devze.com 2023-04-06 22:16 出处:网络
I have a query URL with query string and I want to convert it to folder structured URL. For example: http://localhost/index.php?page=about-us

I have a query URL with query string and I want to convert it to folder structured URL.

For example:

http://localhost/index.php?page=about-us
http://localhost/index.php?page=contact-us

how would I covert it to

http://localhost/index/page/about-us
http://localhost/page/about-us

I know this ca开发者_JAVA技巧n be done with .htaccess. I just don't know where to start


You would need something along the lines of...

Options +FollowSymLinks   
RewriteEngine On   

RewriteCond %{SCRIPT_FILENAME} !-d   
RewriteCond %{SCRIPT_FILENAME} !-f   

RewriteRule ^page/([-a-z-0-9]+)*/$ ./index.php?page=$1
RewriteRule ^index/page/([-a-z-0-9]+)*/$ ./index.php?page=$1
0

精彩评论

暂无评论...
验证码 换一张
取 消