Solved

Rewrite all calls to a file in root

Posted on 2004-08-21
4
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

724 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