Solved

Rewrite all calls to a file in root

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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