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 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2006
    Location
    Newcastle, england.
    Posts
    38
    Thanks
    2
    Thanked 0 Times in 0 Posts

    .htaccess for forcetype method giving 500 server error

    This is really annoying, I'm sure it's something stupid I've done. If anyone can spot anything I've missed, or just plain overlooked then it would be appreciated. Thanks;

    I've just done this site and thought I'd try using the forcetype method to generate more SEF URL's. I wish I hadn't now.

    http://durban.directrouter.com/~espresso/

    I want it to work when I go to http://durban.directrouter.com/~espressso/ethics/

    It should, but doesn't

    My htaccess file;

    Code:
    <files index>
    RewriteEngine on
    
    RewriteBase /
    
    
    # remove .php and THE_REQUEST to prevent loops
    
    RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
    
    RewriteRule (.*)\.php$ $1 [R=301]
    
    
    
    # remove trailling slash
    
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{REQUEST_URI} /$
    
    RewriteRule (.*)/ $1 [R=301]
    
    
    
    # add .php to access file, but don't redirect
    
    RewriteCond %{REQUEST_FILENAME}.php -f
    
    RewriteCond %{REQUEST_URI} !/$
    
    RewriteRule (.*) $1\.php
    
    </files>
    HELP!

  • #2
    New Coder
    Join Date
    Jul 2006
    Location
    Newcastle, england.
    Posts
    38
    Thanks
    2
    Thanked 0 Times in 0 Posts

    etting somewhere!

    OK, so I found out that my host didn't have mod_rewrite turned on, well, they said they did, but it actually wasn't working. They recompiled Apache and it started working!

    I now have the following in my .htaccess file;

    Code:
    # initialise rewrite and set base
    
    RewriteEngine On
    RewriteBase /
    
    # strip index.php if requested
    
    RewriteRule ^(.*)\.php$ http://durban.directrouter.com/~espresso/ [R=301]
    
    RewriteRule ^(.*)\.php?page=([a-z]+)$ /$1/ [R=301]
    It's working well now and when you request index.php, you get redirected to the root ( / ) which is what I wanted, so I have now hidden what file type I'm using.

    The next step is to take any argument passed through the URL (index.php?page=ethics), It would be ?page=ethics in this example.

    I want to redirect so it looks like this

    www.domain.com/ethics/

    I thought the following line would accomplish this;

    Code:
    RewriteRule ^(.*)\.php?page=([a-z]+)$ /$1/ [R=301]
    But apparently it's not that simple (I'll walk through it, if anyone spots anything, feel free to shout up!);

    ^ - Start of expression to be matched
    (.*) - Wildcard, anything
    \ - used to escape the dot before the file extension
    .php - the file type I want to match
    ?page= - This is included in the URL
    ([a-z]+) - Any character from a to z
    + - any amount of iterations of a-z
    $ - end of expression to be matched

    /$1/ - redirect to part in square brackets(with slashes before and after)
    [R=301] - 301 redirect mode

    Anyone see what's wrong? Probably something stupid, I've never done this before, so please be gentle.


  •  

    Posting Permissions

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