简体   繁体   English

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

[英]Rewriting URL with query string question mark in htaccess file php

I have URL like www.yoursite.com/watch?v=OYQ3svsQ8Ys and want to redirect it to www.yoursite.com/index.php?v=OYQ3svsQ8Ys 我有类似www.yoursite.com/watch?v=OYQ3svsQ8Ys URL,并希望将其重定向到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>

The only error in your file is if content <ifModule mod_expires.c> . 文件中唯一的错误是如果内容<ifModule mod_expires.c> Change it to rewrite 更改以rewrite

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM