Forum Moderators: phranque
Secondly I am using the following as htaccess file. The redirection is getting bigger and bigger. Is that ok or is there any other solution to optimize the htaccess file
Options +FollowSymLinks All
RewriteEngine On# -FrontId-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName mysite.com
AuthUserFile /home/mysite/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/mysite/public_html/_vti_pvt/service.grp
RewriteCond %{HTTP_HOST} ^mysite.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.net$
RewriteRule ^(.*)$ http://mysite.com [R=301,L]
RewriteCond %{HTTP_HOST} ^mysite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^/?$ http://mysite.com/bbeta [R=302,L]
RewriteRule ^/?(1)/(user)$ dir/index.php
RewriteRule ^/?(1)/(user)/$ dir/index.php
RewriteRule ^/?(1)/(user)/(submit)$ dir/submit.php
RewriteRule ^/?(1)/(user)/(submit)/$ dir/submit.php
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/([0-9]+)(/*)$ dir/ids.php?sectionid=$1&catid=$2&id=$3&val=$4&title=$5
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ dir/ids.php?sectionid=$1&catid=$2&id=$3&val=$4&title=$5
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/([a-zA-Z])$ dir/display.php?sectionid=$1&catid=$2&id=$3&alphabet=$4
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/([a-zA-Z])/$ dir/display.php?sectionid=$1&catid=$2&id=$3&alphabet=$4
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)$ dir/display.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/$ dir/display.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/(change)$ dir/ew.php
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/(change)/$ dir/ew.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(share)$ f/spreadit/spreadit.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(share)/$ f/spreadit/spreadit.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(post_post_comment)$ f/post_post_comment/post_post_comment.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(post_post_comment)/$ f/post_post_comment/post_post_comment.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(print)$ f/print/printid.php
RewriteRule ^/?([0-9]+)/([0-9]+)/([0-9]+)/(print)/$ f/print/printid.php
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/(pdf)$ f/fpdf/tutorial/pdfmodi.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(1)/([0-9]+)/([0-9]+)/(pdf)/$ f/fpdf/tutorial/pdfmodi.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(2)/(user)$ images/index.html
RewriteRule ^/?(2)/(user)/$ images/index.html
RewriteRule ^/?(2)/(user)/(submit)$ images/upload.php
RewriteRule ^/?(2)/(user)/(submit)/$ images/upload.php
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/([a-zA-Z])$ images/display.php?sectionid=$1&catid=$2&id=$3&alphabet=$4
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/([a-zA-Z])/$ images/display.php?sectionid=$1&catid=$2&id=$3&alphabet=$4
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)$ images/display.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/$ Imagess/display.php?sectionid=$1&catid=$2&id=$3
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/([0-9]+)(/*)$ iamges/ids.php?sectionid=$1&catid=$2&id=$3&val=$4&title=$5
RewriteRule ^/?(2)/([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ images/ids.php?sectionid=$1&catid=$2&id=$3&val=$4&title=$5
You can easily cut the size of your .htaccess file by almost half simply by making better use of regular expressions:
First four rule-sets for example:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.net
RewriteRule (.*) http://example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule ^$ http://example.com/bbeta [R=302,L]
RewriteRule ^1/user/?$ dir/index.php [L]
RewriteRule ^1/user/submit/?$ dir/submit.php [L]
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim