SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2009
    Location
    Finland
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Special Rewrites htaccess

    Hi,

    I have tried to read docs and see help from Google but didnt find for these cases.

    1) I get some requests to my site like domain/.html. How is it possible to redirect those requests to site root. I dont want to use error directive here.

    2) I have a single wordpress installation for multiple sites, but cant figure, if it is possible to have installation to work from domain root. Currently I have direcotry structure like:

    domain/.htaccess
    domain/index.php -> redirects to domain/blog/
    domain/blog/ -> symbolic link to /usr/share/wordpress/

    .htaccess file contains:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>

    Id like to have blog on root so that hxxp://www.domain.ext/ shows the blog. At the moment hxxp://www.domain.ext/blog/ shows the blog.

    My own experiments with rewrite rules just leads to infinite loops and I cant figure out how to do this...

    3) Is it possible to import multiple htaccess files and directive for one directory? I have multiple sites, which have similar lines for handling files, but also domain specific parts. It would be handy to include common part from separate file when I just update that file if changes occurs, not all 20 htaccess files.

    domain/.htaccess -> import /usr/share/.htaccess_common

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,645
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    mm,

    Welcome to SitePoint's Apache forum!

    Did you have a read of the mod_rewrite tutorial linked in my signature. It was developed from years of answering the same questions in this forum over and over and ...

    1) I get some requests to my site like domain/.html. How is it possible to redirect those requests to site root. I dont want to use error directive here.
    The PROPER way is to use ErrorDocument. After all, what IDIOT would use a link like that?

    Okay, if you need to cater to idiots on your site, I understand. If you don't want to use ErrorDocument, I don't understand but we can build mod_rewrite code to do the same thing (only slower). HOWEVER, is it just the .html that you want to send to DocumentRoot (what is the DirectoryIndex?) or ALL 404's?
    2) I have a single wordpress installation for multiple sites, but cant figure, if it is possible to have installation to work from domain root. Currently I have direcotry structure like:

    domain/.htaccess
    domain/index.php -> redirects to domain/blog/
    domain/blog/ -> symbolic link to /usr/share/wordpress/

    .htaccess file contains:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>

    Id like to have blog on root so that hxxp://www.domain.ext/ shows the blog. At the moment hxxp://www.domain.ext/blog/ shows the blog.

    My own experiments with rewrite rules just leads to infinite loops and I cant figure out how to do this...
    That's because it's a circular redirection that you're executing. The way to get blog to DocumentRoot is to MOVE IT to the DocumentRoot (and change the WP configuration files - it's as simple as that).

    If you do, however, REMOVE the <IfModule> brackets as those are a sure sign that you are NOT a competent webmaster. Either you have mod_rewrite enabled or you don't but DON'T test for every file request!
    3) Is it possible to import multiple htaccess files and directive for one directory? I have multiple sites, which have similar lines for handling files, but also domain specific parts. It would be handy to include common part from separate file when I just update that file if changes occurs, not all 20 htaccess files.

    domain/.htaccess -> import /usr/share/.htaccess_common
    [/quote]
    Of course. However, look at the code as there may be conflicting code (especially when WP wants to redirect EVERYTHING [that is not a file or directory] to its own index.php script).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •