Solved

regex for mod_rewrite

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now