douliwang6896
douliwang6896
2015-07-25 18:13
浏览 42
已采纳

在htaccess文件php中用查询字符串问号重写URL

I have URL like www.yoursite.com/watch?v=OYQ3svsQ8Ys and want to redirect it to www.yoursite.com/index.php?v=OYQ3svsQ8Ys

Actually Question mark makes problem I am trying :

 <ifModule mod_expires.c>  
    Options +FollowSymLinks -MultiViews
    RewriteEngine On

    RewriteCond %{QUERY_STRING} ^v=([^&]+) [NC]
    RewriteRule ^watch$ index.php? [NC,L,QSA]
 </ifModule>

图片转代码服务由CSDN问答提供 功能建议

我的网址如 www.yoursite.com/watch?v=OYQ3svsQ8Ys 并希望将其重定向到 www.yoursite.com/index.php?v=OYQ3svsQ8Ys

实际上问号会产生问题 我正在尝试:

 &lt; ifModule mod_expires.c&gt;  
选项+ FollowSymLinks -MultiViews 
 RewriteEngine On 
 
 RewriteCond%{QUERY_STRING} ^ v =([^&amp;] +)[NC] 
 RewriteRule ^ watch $ index.php?  [NC,L,QSA] 
&lt; / ifModule&gt; 
   
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duangong937906
    duangong937906 2015-07-25 18:41
    已采纳

    The only error in your file is if content <ifModule mod_expires.c>. Change it to rewrite

    <ifModule mod_rewrite.c>  
        Options +FollowSymLinks -MultiViews
        RewriteEngine On
    
        RewriteCond %{QUERY_STRING} ^v=([^&]+) [NC]
        RewriteRule ^watch$ index.php? [NC,L,QSA]
     </ifModule>
    
    点赞 评论

相关推荐