Removing trailing slash for sub directory url indexing

后端 未结 1 1736
执念已碎
执念已碎 2021-01-24 05:28
example.com/contact.php  <- I want to like this -> example.com/contact

and this also want...

example.com/contact/ (havent real di         


        
相关标签:
1条回答
  • 2021-01-24 05:51

    Your complete .htaccess can be like that:

    Options +FollowSymLinks -MultiViews
    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} ^col3negmovie\.com$ [NC]
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
    
    RewriteCond %{THE_REQUEST} \s/+watchnew1\.php\?id=([^\s&]+) [NC]
    RewriteRule ^ watch/%1? [R=301,L]
    
    # remove trailing slash
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
    RewriteRule ^(.+?)/$ $1 [R=301,L]
    
    # remove .php extension 
    RewriteCond %{THE_REQUEST} \s/+(.*?)\.php[\s?] [NC]
    RewriteRule ^ %1 [R=301,L,NE]
    
    RewriteRule ^watch/(.+?)/?$ watchnew1.php?id=$1 [L,QSA,NC]
    
    # add .php extension internally
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
    RewriteRule ^(.+?)/?$ $1.php [L]
    
    0 讨论(0)
提交回复
热议问题