replace space by - using htaccess

后端 未结 2 1225
旧巷少年郎
旧巷少年郎 2020-12-18 15:13

hi i have this code in my htaccess


Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} \\s/+sin         


        
2条回答
  •  温柔的废话
    2020-12-18 15:40

    Have your rules like this:

    
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{THE_REQUEST} \s/+single\.php\?title=([^\s&]+) [NC]
    RewriteRule ^ %1/? [R=302,L,NE]
    
    ## Adding a trailing slash
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{THE_REQUEST} \s/+(.*?)[^/][?\s]
    RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301]
    
    # convert %20 to -
    RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [N,NE]
    RewriteRule "^(\S*) (\S*)$" $1-$2 [L,R=302,NE]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+?)/?$ single.php?title=$1 [NE,L,QSA]
    
    

提交回复
热议问题