Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Selective .htaccess rules

    Hi all

    I have an .htaccess rule which redirects users from pages with .html/.htm extensions to .php (I moved the site over from html to php):

    Code:
    # Redirects all .html extensions to .php (for bookmarks on other sites)
    RedirectMatch 301 (.*)\.html$ http://www.domain.com$1.php
    RedirectMatch 301 (.*)\.htm$ http://www.domain.com$1.php
    
    # Custom, SLC-themed 404 error page
    ErrorDocument 404 /404.php
    which works great. But I'm trying to use LimeSurvey and it generates all its template previews with .html extensions, meaning I get a 404 because the equivalent .php file doesn't exist.

    I want the redirect to be available because it is very useful for outside users but I have to be able to work on LimeSurvey in the background.

    Is is possible to make the above rule selective, i.e. applied to all parts of the server except the LimeSurvey folder (.com/survey)?

    Any help much appreciated

  • #2
    New to the CF scene
    Join Date
    May 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the links, but they don't seem to tell me how to make *conditional* rules i.e. rules which are applied only to certain directories on the server.

    Can anyone help?

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Posts
    330
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Code:
    Options +FollowSymLinks
    ErrorDocument 404 /404.php
    
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/survey(/.*)?$ [NC]
    RewriteRule ^(.+\.)html?$ /$1php [R=301,L]

  • Users who have thanked schleppel for this post:

    melat0nin (05-21-2009)

  • #5
    New Coder
    Join Date
    Jun 2007
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by schleppel View Post
    Code:
    Options +FollowSymLinks
    ErrorDocument 404 /404.php
    
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/survey(/.*)?$ [NC]
    RewriteRule ^(.+\.)html?$ /$1php [R=301,L]
    Thank you for the succinct (and correct) answer!

  • #6
    New Coder
    Join Date
    Jun 2007
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by schleppel View Post
    Code:
    Options +FollowSymLinks
    ErrorDocument 404 /404.php
    
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/limesurvey(/.*)?$ [NC]
    RewriteRule ^(.+\.)html?$ /$1php [R=301,L]
    Hello

    I've got an installation of PHPList which uses FCKEditor, and unless I disable these rules it doesn't show up (I get a Forbidden error).

    I tried to include the PHPList path in the exception above:

    Code:
    RewriteCond %{REQUEST_URI} !^/lists(/.*)?$ [NC]
    but it didn't work. Any help would be much appreciated!

    Cheers

  • #7
    Regular Coder
    Join Date
    Oct 2004
    Posts
    330
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Where are the FCKEditor files? Try excluding that directory instead.


  •  

    Posting Permissions

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