Solved

Rewrite all calls to a file in root

Posted on 2004-08-21
4
148 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

22 Experts available now in Live!

Get 1:1 Help Now