homepage Welcome to WebmasterWorld Guest from 184.73.72.163
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirect Optimization and fine tune , efficient way
redirect optimization , redirect fine tune efficient way
kawdo




msg:4185181
 4:59 am on Aug 11, 2010 (gmt 0)

dear all,

i post my htaccess file , this is working fine , but i need efficient way , fine tune . hope your suggestions for speed up .



Options +FollowSymLinks
RewriteEngine On


# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^sri-lanka-classifieds-([^/]+)\.html$ /browse.php?fatherID=$1 [L]

# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /browse\.php\?fatherID=([^&]+)\ HTTP/
RewriteRule ^browse\.php$ [sample.com...] [R=301,L]

# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^sri-lanka-classifieds-([^/]+)-([^/]+)\.html$ /browse.php?fatherID=$1&pageNum=$2 [L]

# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /browse\.php\?fatherID=([^&]+)&pageNum=([^&]+)\ HTTP/
RewriteRule ^browse\.php$ [sample.com...] [R=301,L]


# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^([^/]+)-([^/]+)-([^/]+)-([^/]+)\.html$ /detail.php?Title=$1&fatherID=$2&ListingID=$3&TypeID=$4 [L]

# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /detail\.php\?Title=([^&]+)&fatherID=([^&]+)&ListingID=([^&]+)&TypeID=([^&]+)\ HTTP/
RewriteRule ^detail\.php$ [sample.com...] [R=301,L]


# non www or index.php

RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^sample\.com [nc]
RewriteRule (.*) [sample.com...] [R=301,L]

RewriteCond %{HTTP_HOST} ^sample.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.sample.com$
RewriteRule ^links.php$ [sample.com...] [R=301,L]

# if not found
ErrorDocument 404 /404.php


# 480 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>

# 2 DAYS
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>

# 2 HOURS
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>


<IfModule mod_suphp.c>
suPHP_ConfigPath /home/danweem
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>

 

g1smd




msg:4185208
 6:33 am on Aug 11, 2010 (gmt 0)

Specific-page external redirects should go first.

The "old URL to new URL" external redirects should be next.

The index to slash redirect should be next (and better code is available for that).

The non-www to www external redirect should be the last of the redirects.

All internal rewrites (things with L flag and NO R flag) should be listed after the redirects; with the rewrites ordered from most to least specific.

Never redirect to an index filename. Redirect to URL ending in trailing slash only.

Use [ code ] tags and example.com in your post to stop the forum auto-linking your URLs.


See also: post 4185137 in [webmasterworld.com...]

kawdo




msg:4185215
 7:11 am on Aug 11, 2010 (gmt 0)

i am beginner for this , please rearrange this for me , gr8 help otherwise confusing with few parts from your post.

kawdo




msg:4185216
 7:13 am on Aug 11, 2010 (gmt 0)

what is the meaning of "Specific-page external redirects should go first. " ?

phranque




msg:4185226
 7:30 am on Aug 11, 2010 (gmt 0)

in general your rewriterules should be ordered from most general to most specific and with external redirects before internal rewrite (so you don't expose your internal urls.)

kawdo




msg:4185361
 1:45 pm on Aug 11, 2010 (gmt 0)

thanks

>> The index to slash redirect should be next (and better code is available for that).

what is the new code for this ?

g1smd




msg:4185491
 6:10 pm on Aug 11, 2010 (gmt 0)

It's in part of the post 4185137 of the thread I linked to above.

The comments in that code explain the code.

To use that index redirect code, you'll need to change ".php4" to ".php" and change the domain name the code refers to.

jdMorgan




msg:4185530
 7:40 pm on Aug 11, 2010 (gmt 0)

> in general your rewriterules should be ordered from most general to most specific

That's backwards. Order your redirect and rewrite rule groups from most-specific (one or a few URLs affected) to least-specific (more URLs affected).

Jim

phranque




msg:4186223
 11:53 pm on Aug 12, 2010 (gmt 0)

That's backwards.

my bad!
i must have been thinking dyslexically when i wrote that...
=8)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved