Forum Moderators: phranque

Message Too Old, No Replies

need help to add more ruls

A.php to /sub/B.php and /sub1/ to /sub1/sub2/

         

uzidesign

7:22 am on Oct 24, 2010 (gmt 0)

10+ Year Member



Hi all,

I have phpbb3 forum and add joomla in front.
i add rules viewtopic|viewforum|search|content to new subfolder but
Need help to add more.

1) mydomain.com/gallery -> mydomain.com/forum/gallery
2) mydomain.com/AAAA.php -> mydomain.com/forum/BBBB.php

my htaccess
##
# @version $Id: htaccess.txt 13415 2009-11-03 15:53:25Z ian $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##


#####################################################
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
# mod_rewrite in use

RewriteEngine On
RewriteCond %{HTTP_HOST} ^tukinfo\.com$ [NC]
RewriteRule ^(.*)$ http://www.tukinfo.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.tukinfo.com/ [R=301,L]
RewriteRule ^(viewtopic|viewforum|search|content)\.php /forum/$0 [R=301,L]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)

# RewriteBase /


########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section


Thanks :)
Best Regards,
uzi

g1smd

8:33 am on Oct 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not enough information.

Which of those is a URL used "out on the web"? Include the domain name in those examples.

Which of those represents the internal folder path where the content resides in the server? Omit the domain name from those examples. Domain names are not used "inside the server".

Are you looking to redirect users to a new URL, or are you continuing to use the old URLs but need a rewrite to connect those same URL requests to a different location inside the server?

The answers to all of these questions are critical to understanding "exactly" what you want to do. URLs and filepaths are not at all the same thing, and redirects and rewrites (while sharing similar code) do quite different things.

Additionally, your three domain canonicalisation, index redirect and page redirects are in exactly-backwards wrong order. The order you have produces an unwanted multi-step redirection chain for many non-canonical URL requests.

Those rules should also be placed after the "Rewrite rules to block out some common exploits". There's no point redirecting a request only to block it at the next step.

Finally, the "rewrite" part of the code is very inefficient. New code for that was posted in [webmasterworld.com...] a few weeks ago.

uzidesign

10:37 am on Oct 24, 2010 (gmt 0)

10+ Year Member



Hi,
My English not "the best", but I hope I understand and answer for everything.


Before:
domain (tukinfo.com)
1) phpbb3 forum on the root folder.
2) custom portal with index.php and edit forums to board.php
3) gallery in sub (tukinfo.com/gallery)

Need to be after:
1) phpbb3 in sub folder (tukinfo.com/forum)
2) edit forum back to index.php
3) gallery have now 1 more sub folder (tukinfo.com/forum/gallery)

So I need help if someone url tukinfo.com/board.php
OR tukinfo.com/forum/board.php Then tukinfo.com/forum/index.php (301)

And if someone url tukinfo.com/gallery/somefile.html direct to
Tukinfo.com/forum/gallery/somefile.html


About the order and new code, Do I understand this right now?

##
# @version $Id: htaccess.txt 13415 2009-11-03 15:53:25Z ian $
# @package Joomla
# @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##


#####################################################
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################

## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
# mod_rewrite in use


########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F]
#
########## End - Rewrite rules to block out some common exploits

RewriteEngine On
RewriteCond %{HTTP_HOST} ^tukinfo\.com$ [NC]
RewriteRule ^(.*)$ http://www.tukinfo.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.tukinfo.com/ [R=301,L]
RewriteRule ^(viewtopic|viewforum|search|content)\.php /forum/$0 [R=301,L]

# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)

RewriteBase /

# Add trailing slash if path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) [riococokids.com...] [R=301,L]

# Rewrite [yoursite.com...] to [yoursite.com...]
RewriteCond %{REQUEST_URI} !^/joomla
RewriteRule ^(.*)$ joomla/$1 [L]

########## Begin Joomla! SEF Section
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html?|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]
########## End Joomla! SEF Section



Thank you very much for your help.

jdMorgan

2:46 pm on Oct 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please see Proper order for .htaccess [webmasterworld.com] in our Library and review the resources cited in our Apache Forum Charter [webmasterworld.com]. The other examples and tutorials in our Apache Forum Library [webmasterworld.com] may also prove useful.

In addition, the thread Reducing Costly Rewrites in Wordpress [webmasterworld.com] also discusses an optimization technique that applies equally to any CMS-based site.

Jim