Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-05-2009
Member
 
Join Date: Feb 2006
Posts: 185
problem with mod-rewrite to subdirectory in root

I want to do a cloaked htaccess redirect from my root to the sub so therefore I have just installed a moodle in a subdirectory. I dont know how to use htaccess file so please help me with it.
Reply With Quote
  #2  
Old 21-05-2009
Member
 
Join Date: Dec 2007
Posts: 1,592
Re: problem with mod-rewrite to subdirectory in root

Try this code:
Code:
/.htaccess (htdocs root)
#other rules from above here
RewriteRule ^friendster/([0-9]+)/([^/]+)\.html$ /friendster/search.php?query=$2&search=1&start=$1&a=1 [L]
RewriteRule ^friendster/(.*)\.html$ /friendster/search.php?query=$1&search=1&a=1 [L]

RewriteRule ^friendster/(.*)-(.*).html?$ /friendster/details.php?id=$1&titlecode=$titlecode3=$2 [L]
RewriteRule ^friendster/preview/(.*)-(.*).html?$ /friendster/preview.php?id=$1&titlecode=$titlecode3=$2 [L]
Also see the RewriteBase directive for your sub-directory's .htaccess file:
http://httpd.apache.org/docs/2.2/mod...ml#rewritebase
Reply With Quote
  #3  
Old 21-05-2009
Member
 
Join Date: Dec 2007
Posts: 1,542
Re: problem with mod-rewrite to subdirectory in root

The best way to manage the change of site?s URL due to movement of directory location is by using redirection feature provided by mod_rewrite module in Apache HTTPD web server. Most web hosts using Apache web server supports mod_rewrite redirect by default, and can implement this trick with ease. Else you will need to enable and turn on mod_rewrite module.

To redirect from a subdirectory or sub-folder to root directory, add the following line of text towards the top of .htaccess file located in the sub-directory to redirect all requests into that folder will be redirected to new location (i.e. root) properly. If the .htaccess file does not exist, create one.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^mylovelysite/(.*)$ /$1 [R=301,NC,L]
</IfModule>

Replace mylovelysite in the forth line above with the directory name on your website?s URL. These line in .htaccess will redirect requests for the /mylovelysite sub-directory to the root directory by stripping ?mylovelysite/? out of the URL. For example, a visit to http://www.domain.com/mylovelysite/index.html will get redirected to http://www.domain.com/index.html, instead of returning an 404 error. This is useful for visitors who come to your site via bookmark or favorite, or those find your web pages via search engines that haven?t re-crawled, re-spidered and refreshed with the new URLs in their search indexes in the initial days after moving.

Source: mydigitallife.info
Reply With Quote
  #4  
Old 21-05-2009
Member
 
Join Date: Jun 2006
Posts: 620
Re: problem with mod-rewrite to subdirectory in root

.htaccess uses apache rewrite.
I'm not sure if you're refering to using rewrite rules in httpd.conf or not, but using .htaccess, you have the same availability to the apache rewrite engine without having to restart apache (as long as mod_rewrite is already turned on).
other than that, it's really just a matter of preference, and the fact that a bad rewrite rule will result in a 500 error, it's nice to keep that 500 error localized.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "problem with mod-rewrite to subdirectory in root"
Thread Thread Starter Forum Replies Last Post
DCDiag Test - DNS Root hints list has invalid root hint server Sean Windows Server Help 5 07-06-2010 10:47 PM
Picasa problem - only root user can execute it Triple-X Windows Software 5 09-01-2010 01:51 PM
Convert Enterprise Root CA to Standalone Root CA and create newSubordinate CAs SocialAbility Windows Security 2 05-03-2009 05:12 AM
How to resolve error of "Root hints list has invalid root hint ser SinguIar Active Directory 3 13-10-2007 06:16 PM
Initialize the root folders to dispay problem in office 2007 akbar MS Office Support 2 21-02-2007 11:33 AM


All times are GMT +5.5. The time now is 07:21 PM.