Results 1 to 8 of 8

Thread: override htaccess for subdomain

  1. #1
    Registered
    Join Date
    Sep 2013
    Location
    San Francisco
    Posts
    5
    Rep Power
    0

    override htaccess for subdomain

    Hi all,

    I have this as my htaccess in my root folder - to redirect php requests to an extensionless url

    RewriteEngine On

    # Unless directory, remove trailing slash
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/$ http://www.domain.com/$1 [R=301,L]

    # Redirect external .php requests to extensionless url
    RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
    RewriteRule ^(.+)\.php$ http://www.domain.com/$1 [R=301,L]

    # Resolve .php file for extensionless php urls
    RewriteRule ^([^/.]+)$ $1.php [L]

    This is working great except that I have a "blog" subfolder that's a wordpress installation, and this htaccess is messing it up. I need to write another htacess for this "blog" folder that undoes what the above is doing...i.e. to treat php requests normally.

    Thanks!

    David

  2. #2
    target='_blank' snowmaker's Avatar
    Join Date
    Nov 2002
    Location
    West Virginia
    Posts
    3,455
    Rep Power
    21
    Welcome to the Forum, and sorry for the delay getting your post approved. Note that there's a five post limit for newusers, so there'll be some more delays no doubt..

    I think if you just create a blank .htaccess in that subfolder it'll override the htaccess in the parent folder. Try it and see. I'm not certain, but I'll look it up and make another post in this thread.
    -bruce /* somdcomputerguy */
    'If you change the way you look at things, the things you look at change.'

  3. #3
    Registered
    Join Date
    Sep 2013
    Location
    San Francisco
    Posts
    5
    Rep Power
    0
    Thanks Bruce.
    Yeah, that made sense to em and I tried that, but it didn't work. I'll try it again...

  4. #4
    Registered
    Join Date
    Sep 2013
    Location
    San Francisco
    Posts
    5
    Rep Power
    0
    no, it didn't work...can't access that folder...says "No input file specified."

  5. #5
    target='_blank' snowmaker's Avatar
    Join Date
    Nov 2002
    Location
    West Virginia
    Posts
    3,455
    Rep Power
    21
    So far I've only been able to find this code snip, which would go into the apache configuration file (htppd.conf), which we don't have access to. But try this anyway, in the parent .htaccess. If that causes an error or doesn't work, try it (without the directory tags) in a htaccess in the subfolder.
    Code:
    # Disable .htaccess in this path
    <Directory /cannot/use/htaccess/*>
    AllowOverride None
    </Directory>
    -bruce /* somdcomputerguy */
    'If you change the way you look at things, the things you look at change.'

  6. #6
    Registered
    Join Date
    Sep 2013
    Location
    San Francisco
    Posts
    5
    Rep Power
    0
    unfortunately, neither worked. Thanks though.

  7. #7
    Custom User Title tpoynton's Avatar
    Join Date
    Sep 2004
    Location
    Mass
    Posts
    2,177
    Rep Power
    18
    There has to be a way to say 'if the folder is not the blog folder, process the rewrite'...after a little googling, try the code below...I do not expect it will work because I do not know htaccess, but I think this is the way to proceed - instead of dealing with the issue after it occurs, prevent it from occuring
    Code:
    RewriteEngine On
    
    # Unless directory, remove trailing slash
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)/$ http://www.domain.com/$1 [R=301,L]
    
    # Redirect external .php requests to extensionless url
    RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
    RewriteRule ^(?!BlogSubfolderName).*$
    RewriteRule ^(.+)\.php$ http://www.domain.com/$1 [R=301,L]
    # Resolve .php file for extensionless php urls
    RewriteRule ^([^/.]+)$ $1.php [L]

  8. #8
    Registered
    Join Date
    Sep 2013
    Location
    San Francisco
    Posts
    5
    Rep Power
    0
    Thanks both of you!

    Actually, I tried the following...putting this in the blog folder (subdirectory)

    RewriteEngine On
    RewriteBase /

    A blank .htaccess in this folder didn't work, but this did...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •