LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-05-2015, 03:06 PM   #1
brunofontaine
LQ Newbie
 
Registered: May 2015
Posts: 2

Rep: Reputation: Disabled
What does this rewrite rule actually do?


When looking at .htaccess on our server, I see that the developers included the following lines:

RewriteRule (services/.*) $1 [L] # adjust the regex to what you want.
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]

No idea what the first RewriteRule actually does
Not sure about the ^$ in the 2nd rule
I understand the 3rd rule.


I would appreciate a quick explanation. Thank you very much in advance.

Last edited by brunofontaine; 05-05-2015 at 03:34 PM.
 
Old 05-05-2015, 07:31 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,472

Rep: Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618Reputation: 618
In regex ^ anchors to the start of a line, $ anchors to the end of a line, so ^$ matches the empty line.
 
1 members found this post helpful.
Old 05-06-2015, 06:04 AM   #3
Tim Abracadabra
Member
 
Registered: May 2014
Location: USA, Wherever I may Roam
Distribution: Debian w/Xfce, LFS 7.9, ++
Posts: 117

Rep: Reputation: Disabled
Hi brunofontaine and welcome to LQ!

Regarding the first RewriteRule:
Code:
RewriteRule (services/.*) $1 [L] # adjust the regex to what you want.
(services/.*) is the pattern match so matches against a directory or url path
that (minus the domain name) includes and ends with services/

The .* that follows matches any single character and any that follow it.

The $1 in this case is the target and is a variable that holds the value matched in the parenthesis.

Examples:

services/myapp.php will select the target services/myapp.php and if found will return that to the requestor.

myandroidservices/myapp.php however will still select the target services/myapp.php and again if found will return that to the requestor.

Note that in a browser the URL will not change to the target even if it is different
as in the second example as this particular rule is a essentially mapping function and not a redirect.

Here is more info on Mod_Rewrite.

Hope that helps,

Tim

Last edited by Tim Abracadabra; 05-06-2015 at 06:18 AM. Reason: Add browser note
 
1 members found this post helpful.
Old 05-06-2015, 07:23 PM   #4
brunofontaine
LQ Newbie
 
Registered: May 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thank you.

Thank you for your detailed replies. Very informative.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache rewrite rule sunlinux Linux - Newbie 10 11-11-2011 06:01 AM
htaccess rewrite rule asifbasha Linux - Server 1 09-21-2011 01:48 PM
need on rewrite rule help ravibhure Linux - Newbie 5 09-09-2010 02:03 PM
apache2 rewrite rule help razzera Linux - Server 7 08-17-2010 05:39 PM
i need a rewrite rule!help arcow Linux - Enterprise 1 07-03-2007 06:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration