Solved

regex for mod_rewrite

Posted on 2006-10-28
5
194 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

20 Experts available now in Live!

Get 1:1 Help Now