[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

.htaccess rewrite rules

Posted on 2013-12-04
3
Medium Priority
?
198 Views
Last Modified: 2014-07-23
Can you write a rewriteRule for a .htaccess file that will accomplish the following:
redirect xyz.com/test and xyz.com/test/?id=1 to google.com
exclude xyz.com/tester and xyz.com/test/tester?

You must allow query strings and hash tags to flow through the redirects.

If I didn't need this solution asap I would spend the time to learn it myself but I unfortunately do not have the time. Thank you experts.
0
Comment
Question by:aristanoble
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 51

Assisted Solution

by:Steve Bink
Steve Bink earned 800 total points
ID: 39698630
Try this:
RewriteCond %{QUERY_STRING} ^id=1$ [OR]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/?test/?$ http://google.com [R,L,QSA]

Open in new window

As far as I know, there's no way to detect or act on a fragment.  Then again, I've not experimented with it much.  The fragment is a client-side instruction which is not generally important at the server level.
0
 
LVL 27

Accepted Solution

by:
skullnobrains earned 1200 total points
ID: 39893176
assuming you want to redirect
/test
/test/?anything
but not
/test/
/test/anything_that_does_not_start_with_?

RewriteRule ^/?test(/?|$) http://google.com

if you're uncomfortable with the above, you might as well write multiple rewrite rules
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question