SEO friendly URLs (.htaccess)

前端 未结 2 443
星月不相逢
星月不相逢 2020-12-12 04:05
http://www.domain.com/folder/file?x=1&y=2

Change to:

http://www.domain.com/folder/file/1/2/

htt         


        
相关标签:
2条回答
  • 2020-12-12 04:13

    Did you try adding a / before the folder name?

    RewriteRule ^folder/(.*)/$ /folder/index.php?x=$1 [L]
    RewriteRule ^folder/file/(.*)/(.*)/$ /folder/file.php?x=$1&y=$2 [L]
    
    0 讨论(0)
  • Try

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^folder/file/(.*)/(.*)/ /folder/file.php?x=$1&y=$2 [L]
    RewriteRule ^folder/(.*)/ /folder/index.php?x=$1 [L]
    

    The order of the rules is important. You should always put the one with the most rules first as your way was getting to the first rule and then stopping because it was always true due to the (.*) which was capturing the file.

    0 讨论(0)
提交回复
热议问题