Solved

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

Posted on 2014-12-10
2
145 Views
Last Modified: 2014-12-27
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
Comment
Question by:Jacobbaby
2 Comments
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 40495204
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
This video teaches users how to migrate an existing Wordpress website to a new domain.

829 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