Jump to content

End Rewrite process by L-Flag?


Standart

Recommended Posts

Hi,

 

I'm pretty new to RewriteRules. Here's my scenario:

 

In a .htaccess file I want to redirect (301) url path "old" to url path "new". Like this:

 

RewriteRule ^old$ /new [R=permanent]

 

Additionally I want to rewrite url path "new" to the existing file "old" (no external redirect):

 

RewriteRule ^new$ old

 

These two rules work perfectly unless I try to use them both. I tried to use the L-flag which stops the rewrite process according to the apache docs:

 

RewriteRule ^new$ old [L]
RewriteRule ^old$ /new [L,R=permanent]

 

Now if I request http://mydomain.net/old or http://mydomain.net/new I get a 301 to the location http://mydomain.net/new and in an infinite loop. I understand that but as I understood the L-flag I could stop this loop being the last rewrite statement to be processed. I assumed that the redirect rule would initiate a new request to "new" and that request would be rewritten to "old" without invoking the redirect again.

 

Of course I could rename my original file but I'm interested in how the L-flag really works. Anyone an explanation?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.