Jump to content

Recommended Posts

I have the following Mod_Rewrite...

RewriteEngine on

#PRETTY:		articles/postage-meters-can-save-you-money
#UGLY:			article.php?slug=postage-meters-can-save-you-money

RewriteRule articles/([a-zA-Z0-9_-]+)$ article.php?slug=$1

 

Someone told me I need to close it out with an [L] or something, but they weren't very clear.

 

Can someone help me figure out what might be wrong with the above code which seems to be working fine?

 

BTW, in my Dev environment, the above code is all I have in my .htaccess file, however in Production I will probably have other code - which I really don't understand - that does things like make sure my site starts with "www" and redirects for old pages that are dead.

 

Maybe now is time for .htaccess/Mod_Rewite "housecleaning?!  :shy:

 

Thanks,

 

 

Debbie

 

Link to comment
https://forums.phpfreaks.com/topic/254229-what-is-l-for/
Share on other sites

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

last|L Stop the rewriting process immediately and don't apply any more rules. Especially note caveats for per-directory and .htaccess context (see also the END flag).

 

Rewrite rules can be chained together so something can be re-written multiple times.  Using [L] will cause the process to stop after the rule is applied.  There are many flags that can be set.  The manual page I linked above explains all of them.

 

Link to comment
https://forums.phpfreaks.com/topic/254229-what-is-l-for/#findComment-1307116
Share on other sites

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

last|L Stop the rewriting process immediately and don't apply any more rules. Especially note caveats for per-directory and .htaccess context (see also the END flag).

 

Rewrite rules can be chained together so something can be re-written multiple times.  Using [L] will cause the process to stop after the rule is applied.  There are many flags that can be set.  The manual page I linked above explains all of them.

 

How does my .htaccess file look??

 

#----------------------------------------------------------
#Eliminate index.php.
RewriteEngine on
RewriteCond %{THE_REQUEST} "GET /index.php HTTP/1.1"
RewriteRule index\.php http://www.mywebsite.com/ [R=301,L]


#----------------------------------------------------------
#Redirect all non-www calls to www.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


#----------------------------------------------------------
# Build Date: 2012-01-03 2:20pm

RewriteEngine on

#PRETTY:		articles/postage-meters-can-save-you-money
#UGLY:			article.php?slug=postage-meters-can-save-you-money

#RewriteRule articles/([a-zA-Z0-9_-]+)$ article.php?slug=$1

RewriteRule articles/([a-zA-Z0-9_-]+)$ articles/article.php?slug=$1


#----------------------------------------------------------
#Clean up Dead Links in Google.
Redirect 301 /browse/articles/3 http://www.mysite.com/article_index.php

 

 

Thanks,

 

 

Debbie

 

Link to comment
https://forums.phpfreaks.com/topic/254229-what-is-l-for/#findComment-1307118
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.