Solved

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

Posted on 2014-12-10
2
142 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
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…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

930 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now