Getting Value and redirect with htaccess

前端 未结 1 1387
清歌不尽
清歌不尽 2021-01-20 11:03

I want redirect http://example.com/search/search.php?q=videos to http://example.com/search/videos

I tried to do it but its not work. here

相关标签:
1条回答
  • 2021-01-20 11:20

    Use this code in /search/.htaccess:

    Options +FollowSymLinks -MultiViews
    RewriteEngine On
    RewriteBase /search/
    
    RewriteCond %{THE_REQUEST} /search\.php\?q=([^\s&]+) [NC]
    RewriteRule ^ %1? [R=301,L,NE]
    
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]
    
    RewriteRule ^([^/]+)/?$ search.php?q=$1 [L,QSA]
    
    RewriteRule ^[^/]+/([0-9]+)/?$ search.php?q=$1&p=$2 [L,QSA]
    
    0 讨论(0)
提交回复
热议问题