Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

Implementing url rewriting using .htaccess file without affecting $_SERVER['SCRIPT_NAME']

Dear All,

I want to setup a SaaS(Software as a Service) version of my ERP product. Each of the user who purchases the product can access the product using a url which will be specific for each user (For Example: http://erp.com/user1/). But there will not be a physical folder created for each user, it will be a virtual one and there will be a single copy of the program file will be there and which will be in the root directory.

I have tried with a htaccess file and here with include the code i have written, it is not generic solution it will work only for the case of 'folder1'
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^folder1/(.*)$ /$1 [QSA]
</IfModule>

The problem is when I implement the $_SERVER['SCRIPT_NAME'] returns  'http://erp.com/', instead of this i need to get 'http://erp.com/folder1/' also please suggest me a generic solution for the problem.

Thank you.
0
Jacobbaby
Asked:
Jacobbaby
1 Solution
 
Steve BinkCommented:
You'll need to send that information some other way.  For example:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/?([^/]+)/(.*)$ /$2?actual_folder_name=$1 [QSA]
</IfModule> 

Open in new window

In that example, the folder's name will be available as $_GET['actual_folder_name'].
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.

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