Solved

regex for mod_rewrite

Posted on 2006-10-28
5
201 Views
Last Modified: 2008-03-06
i suck at regex.
need to match / to go to /foo
0
Comment
Question by:qwertq
[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
  • 2
  • 2
5 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 17826971
Just /  -> /foo or also /*** to /foo/**** ?

In the first case you can use

RewriteRule /$ /foo [L]

In the second case:

RewriteRule /(.*) /foo/$1

-r-
0
 

Author Comment

by:qwertq
ID: 17827056
dosn't work (and just want first case)

## MOD_REWRITE STUFF
RewriteEngine On

# Redirect home
RewriteRule /$ /home [L]
0
 
LVL 16

Expert Comment

by:HackneyCab
ID: 17827100
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?
0
 

Author Comment

by:qwertq
ID: 17827143
that works hackney.
but how can i make it not happen silently? i want it to rewrite the url bar
0
 
LVL 16

Accepted Solution

by:
HackneyCab earned 100 total points
ID: 17827224
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.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

623 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