.htaccess friendly URl

前端 未结 1 724
悲&欢浪女
悲&欢浪女 2020-12-19 16:10

Can anybody please help me with some URL rewriting?

I had: (EXAMPLES)

www.example.com/index.php?page=namepage
www.example.com/index.php?page=gallery&         


        
相关标签:
1条回答
  • 2020-12-19 16:24
    ### all your redirects
    
    # for www.example.com/index.php?page=homepage&paging=1
    RewriteCond %{THE_REQUEST} \?page=([^&]+)&paging=([0-9]+)
    RewriteRule ^ /%1/%2? [L,R=301]
    
    # for www.example.com/index.php?page=gallery&topic=nametopic
    RewriteCond %{THE_REQUEST} \?page=([^&]+)&topic=([^&\ ]+)
    RewriteRule ^ /%1/%2? [L,R=301]
    
    # for www.example.com/index.php?page=namepage
    RewriteCond %{THE_REQUEST} \?page=([^&\ ]+)($|\ )
    RewriteRule ^ /%1? [L,R=301]
    
    # for www.example.com/namepage/
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    
    ### all your rewrites back
    
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/([0-9]+)$ /index.php?page=$1&paging=$2 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/([^/]+)$ /index.php?page=$1&topic=$2 [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)$ /index.php?page=$1 [L]
    
    0 讨论(0)
提交回复
热议问题