• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Rewrite all calls to a file in root

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
liquidblaze
Asked:
liquidblaze
  • 3
1 Solution
 
rama_krishna580Commented:
Hi,

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

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

R.K
0
 
rama_krishna580Commented:
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
 
liquidblazeAuthor Commented:
yes. that will work out. sorry for the long response time. added 50 points as an excuse :)
0
 
rama_krishna580Commented:
Hi,

Nice to hear you have solved your problem,

Best of luck..
R.K
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now