duankange2433 2015-04-02 06:41
浏览 58

如果在其网址中发生更改,则重定向网页

I have this page that is daynamic with URL parameters:

/artandculture/details.php?articleid=28208&parentid=1&catid=166

and i want that if user change in URL then it redirect to main URL,e.g any change in URL then redirect to:

/artandculture/details.php?articleid=28208&parentid=1&catid=166

Is there solution with .htaccess?

  • 写回答

1条回答 默认 最新

  • doufei1988 2015-04-02 07:49
    关注

    After your confirmation, Try this solution with htaccess

    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} ^/artandculture/details\.php
    RewriteCond %{QUERY_STRING} !^articleid=[0-9]+&parentid=[0-9]+&catid=[0-9]+$
    RewriteRule .* /artandculture/details.php?articleid=28208&parentid=1&catid=166 [L,NC,R=307]
    

    RewriteCond will check that is requested uri is your perticuler page then next will excute. And next RewriteCond will check if GET parameters are not there OR in wrong format then change the URL to main PAGE.

    Removing ,R=307 from last rule will not redirect(change the address in browser), this will just display the main page with user changed URL.

    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数