我有这个页面是daynamic与URL参数:重定向页面,如果改变它的URL发生
/artandculture/details.php?articleid=28208&parentid=1&catid=166
,我想,如果在URL用户的变化,然后将其重定向到主网址,如发生任何变化URL然后重定向到:
/artandculture/details.php?articleid=28208&parentid=1&catid=166
是否与.htaccess
解决方案?
我有这个页面是daynamic与URL参数:重定向页面,如果改变它的URL发生
/artandculture/details.php?articleid=28208&parentid=1&catid=166
,我想,如果在URL用户的变化,然后将其重定向到主网址,如发生任何变化URL然后重定向到:
/artandculture/details.php?articleid=28208&parentid=1&catid=166
是否与.htaccess
解决方案?
您的确认后,尝试这种解决方案与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
将要检查的请求的URI是你perticuler页面,然后接下来会EXCUTE。接下来RewriteCond
将检查GET参数是否存在或格式错误,然后将URL更改为主页面。
从最后一条规则中删除,R=307
将不会重定向(更改浏览器中的地址),这将只显示包含用户更改URL的主页面。
需要更多信息:你的意思是什么改变?你能举出你想重定向的示例URL吗? ** | **按照我的理解,如果用户在参数名称中更改或者在'details.php'之后有一些错误的语法,您希望重定向,则可以更改GET值(主要是整数)来创建动态页面。 **和**网址之前**?**不容易知道的变化因为你会有一些其他网页 - 在您的网站的网址。 – 2015-04-02 06:55:45
假设用户(网站的访问者)将URL改为:/artandculture/details.php,那么我希望它重定向到主URL:/artandculture/details.php?articleid=28208&parentid=1&catid=166 – Kaveh 2015-04-02 07:02:28
如果用户刚刚输入'/artandculture/details.php'应该总是被重定向到'/artandculture/details.php?articleid = 28208&parentid = 1&catid = 166'? – anubhava 2015-04-02 09:28:00