Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

regex for mod_rewrite

Posted on 2006-10-28
5
Medium Priority
?
207 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 400 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

963 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