Solved

Rewrite all calls to a file in root

Posted on 2004-08-21
4
151 Views
Last Modified: 2010-04-20
hello experts,

I'd like to know if its possible to use mod_rewrite to rewrite a call to say www.domain.com/path/subdir/ to www.domain.com/script.php?path=path/subdir/

my ideas were

RewriteRule ^/script\.php(.*)-[L]
RewriteRule ^(.*)/script\.php?path=$1

but I only get a 500.

any ideas?
0
Comment
Question by:liquidblaze
  • 3
4 Comments
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 11877789
Hi,

look at here..you will get some idea ..

http://www.experts-exchange.com/Web/Web_Servers/Q_21099150.html

R.K
0
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 300 total points
ID: 12120076
Here is some example...

#
# http://sub.domain.com/en/file.php?foo=bar
# to http://www.domain.com/file.php?site=sub&lang=en&foo=bar
#
RewriteEngine On
# Extract the subdomain part, it will be stored into %1
# [^.]+ means: match all characters except the dot
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC]
# We make sure it's not the main host, ie www.example.com
RewriteCond %1 !^www$ [NC]
# Check to avoid internal endless loops
RewriteCond %{REQUEST_URI} !^/file\.php$ [NC]
# Let's go and make an internal redirection
# by redirecting
# sub.example.com/language/filename.php
# to www.example.com/filename.php?site=sub&lang=language&etc
RewriteRule ^([^/]+)/[^.]+\.php$ /$2.php?site=%1&lang=$1 [QSA,L]

R.K
0
 
LVL 2

Author Comment

by:liquidblaze
ID: 12166956
yes. that will work out. sorry for the long response time. added 50 points as an excuse :)
0
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 12166981
Hi,

Nice to hear you have solved your problem,

Best of luck..
R.K
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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