How to use htaccess to change site.com/directory/ to site.com/ ?

Discussion in 'Apache' started by misohoni, Jul 3, 2008.

  1. #1
    I'm using Wordpress as my base and have been getting headaches as to how to intergrate a directory. I'd prefer to keep it at site.com rather than a subdomain.site.com, so would changing site.com/directory/ to site.com/ work? The current /index.php in site.com/ is being used by Wordpress.

    Can anyone help?
     
    misohoni, Jul 3, 2008 IP
  2. apachehtaccess

    apachehtaccess Guest

    Messages:
    82
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    huh? could you explain more?
     
    apachehtaccess, Jul 3, 2008 IP
  3. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Ok..I'm using Wordpress on the root of my site, but now want to use other software which I've installed on a catalog/ directory.

    The posts will look like catalog/page.php - but how can I change it to site.com/page.php instead of site.com/catalog/page.php
     
    misohoni, Jul 3, 2008 IP
  4. apachehtaccess

    apachehtaccess Guest

    Messages:
    82
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok still confused sorry..

    So you want wordpress to handle all files/urls except the files/urls in the /catalog/ directory which will be handled by other software?


    Explain what that means and I can hook you up.
     
    apachehtaccess, Jul 3, 2008 IP
  5. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #5
    hehe, nope!

    i'd like to configure the htaccess so that when someone types site.com/catalog/page.php it redirects them to site.com/page.php

    Normally the catalog goes into the root directory, but Wordpress is already there so would like to somehow integrate the two softwares so that the user doesn't notice catalog/ is in a directory.

    Thanks
     
    misohoni, Jul 3, 2008 IP
  6. innoxed

    innoxed Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    URL rewriting could work in that case
     
    innoxed, Jul 4, 2008 IP
  7. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #7
    ok, how could i use url rewriting... hmm
     
    misohoni, Jul 5, 2008 IP
  8. innoxed

    innoxed Peon

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    first what do you mean when you say that /catalog/page.php should redirect to /page.php?

    you want a real redirection (301, 302), or do you want this to be transparent to the end user?

    Here is are rule you could use to make this transparent:
    RewriteRule ^catalog/page\.php$ /page.php [L]

    Cheers.
     
    innoxed, Jul 5, 2008 IP
  9. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #9
    Thanks, but catalog/page.php is just an example of one of many pages on the site.

    So to redirect catalog to the homepage would be?:

    RewriteRule ^catalog/$ / [L]

    Cheers
     
    misohoni, Jul 5, 2008 IP
  10. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #10
    That would work just for that directory, and it wouldn't work for any sub-files... and I think you asked for urls to be rewrite other way around. You can try something like this:

    
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^([^/]+)$ /catalog/$1 [L]
    RewriteRule ^$ /catalog/ [L]
    
    Code (markup):
    I'm not sure if you have any subfolders in there (in that catalog dir)... if you do, then you'll need some additional rule for that also.
    This will rewrite your files from catalog/ subfolder to your main url. That's what you need, right?
     
    pr0t0n, Jul 5, 2008 IP
  11. misohoni

    misohoni Notable Member

    Messages:
    1,717
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    200
    #11
    Thanks man, that worked
     
    misohoni, Jul 7, 2008 IP