English 中文(简体)
htaccess redirect for existence of a specific URL changing
原标题:htaccess redirect for existence of a specific URL variable

我经过几个小时的辛勤阅读,仍然找不到我所需要的东西! 希望这里的人能够提供帮助。

我想要实现的是,将特定URL重新定位到另一页,但如果没有其他的URL变量。

例如。

  • index.php?option=com_user - this needs to be redirected to index.php
  • index.php?option=com_user&view=login - this must not be redirected
  • index.php?option=com_user&view=login&foo=bar - this must not be redirected

我发现许多例子可以证明存在某种变数,但我想测试这种变数,并测试不存在其他变数。

谁能帮助?

提前感谢。

最佳回答

可以说,如果你只是进行内部调整,那么如果没有其他参数,你的文字就只能忽视这一参数。 但是,这 t你要求的话,因此,请看如何能够用<条码>mod_rewrite<>。

如果我们只是想看一下是否有任何thing? 在问讯中,我们只能检查<代码>option=com_user。 只有:

RewriteEngine On

RewriteCond %{QUERY_STRING} =option=com_user [NC]
RewriteRule index.php index.php?

然而,这仍然允许<代码>/index.php?option=com_user&complete=nonsense通过,这样,如果我们想稍加限制,我们就可以做这样的事情:

RewriteEngine On

# Check if the query string contains option=com_user
RewriteCond %{QUERY_STRING} (^|&)option=com_user(&|$)
# Check that all of these other parameters were not provided
RewriteCond %{QUERY_STRING} !(^|&)view=
RewriteCond %{QUERY_STRING} !(^|&)foo=
RewriteRule index.php index.php?
问题回答

暂无回答




相关问题
Ignore symlinks in clean URL s in .htaccess

Example URL: example.com/user /user is both a symlinked directory and a valid URL to content on my site. I user Horde Routes to request the content and all requests to the site go through index.php. ...

.htaccess File Options -Indexes on Subdirectories

I have the following .htaccess line, simple no indexes on root. Options -Indexes What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on ...

Mod Rewrite ignoring -d

After a day or two, I am still fighting with Mod Rewrite. It seems that 60% of my development time is spent battling the server. My current URL structure is such that all http://example.com/xyz and ...

ErrorDocument 404 Not Sending Referrer Information: PHP

I m using a standard htaccess ErrorDocument 404 to redirect users to a new page. In order to customize the 404, I need to know their referrer information (from the page they Tried to visit). $...

Find all htaccess files on server [closed]

I m looking for a Linux command to go through all the directories on my server and find all .htaccess files. The output would be a list of all those files with full path, creation/modification date ...

301 Redirect Help with Dynamic URL s and Multiple Id s

I just did a redesign for www.wildchildclothes.com which has a new URL structure. The old site ran on Zen Cart and had a bad URL structure. Here are some examples of what I want to redirect from: OLD:...

热门标签