Results 1 to 4 of 4

Thread: problem with mod-rewrite to subdirectory in root

  1. #1
    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.

  2. #2
    Join Date
    Dec 2007
    Posts
    1,599

    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

  3. #3
    Join Date
    Dec 2007
    Posts
    1,547

    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

  4. #4
    Join Date
    Jun 2006
    Posts
    623

    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.

Similar Threads

  1. Replies: 5
    Last Post: 07-06-2010, 10:47 PM
  2. Picasa problem - only root user can execute it
    By Triple-X in forum Windows Software
    Replies: 5
    Last Post: 09-01-2010, 01:51 PM
  3. Replies: 2
    Last Post: 05-03-2009, 05:12 AM
  4. Replies: 3
    Last Post: 13-10-2007, 06:16 PM
  5. Replies: 2
    Last Post: 21-02-2007, 11:33 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,569,118.62577 seconds with 16 queries