Vanity URLs without trailing slashes on Apache

后端 未结 4 650
天命终不由人
天命终不由人 2021-01-21 18:13

The code below rewrites all URLs in the /profiles/ directory on our site from example.com/profiles/name/ to example.com/name/, but we\'d also like to r

4条回答
  •  梦谈多话
    2021-01-21 18:56

    Use the following redirection:

    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} /(.+)/+$
    RewriteRule ^ /%1 [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ /profiles/$0 [NC,L]
    

提交回复
热议问题