We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

regex for mod_rewrite

qwertq
qwertq asked
on
Medium Priority
235 Views
Last Modified: 2008-03-06
i suck at regex.
need to match / to go to /foo
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006

Commented:
Just /  -> /foo or also /*** to /foo/**** ?

In the first case you can use

RewriteRule /$ /foo [L]

In the second case:

RewriteRule /(.*) /foo/$1

-r-

Author

Commented:
dosn't work (and just want first case)

## MOD_REWRITE STUFF
RewriteEngine On

# Redirect home
RewriteRule /$ /home [L]
RewriteRule ^$ /foo

Do you need a redirect for the index file too? Does the rewrite need to send a redirect to the browser, or happen silently?

Author

Commented:
that works hackney.
but how can i make it not happen silently? i want it to rewrite the url bar
If you want to let the world know that this is a permanent arrangement (i.e. not temporary, and links should now point to the new URL) then the 301 redirect status is the one for you:

RewriteRule ^$ /foo [R=301]

That should do the trick.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.