.htaccess problem.. [index.php to /index/]

Discussion in 'Apache' started by bLaZ3n, Apr 3, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I am having problems converting my URLS..

    From: www.scrimsnow.com/index.php

    To: www.scrimsnow.com/index/

    Below is what I have in my .htaccess file.

    # -Manipulate URLs-
    
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index/$ index.php [L]
    RewriteRule ^myaccount/$ myaccount.php [L]
    RewriteRule ^console/$ console.php [L]
    RewriteRule ^about_us/$ about.php [L]
    RewriteRule ^logout/$ logout.php [L]
    RewriteRule ^login/$ login.php [L]
    RewriteRule ^privacy/$ privacy.php [L]
    RewriteRule ^site_map/$ sitemap.php [L]
    RewriteRule ^staff/$ staff.php [L]
    RewriteRule ^sponsors/$ sponsors.php [L]
    RewriteRule ^ucp/$ ucp.php [L]
    
    # -Force non-www URLs-
    
    RewriteCond %{HTTP_HOST} ^www\.scrimsnow\.com$ [NC]
    RewriteRule ^(.*)$ http://scrimsnow.com/$1 [R=301,L]
    PHP:
     
    bLaZ3n, Apr 3, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/$ $1.php [L]
     
    Nintendo, Apr 3, 2007 IP
  3. bLaZ3n

    bLaZ3n Banned

    Messages:
    259
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That didnt work.
     
    bLaZ3n, Apr 4, 2007 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Try it with

    # -Force non-www URLs-

    RewriteCond %{HTTP_HOST} ^www\.scrimsnow\.com$ [NC]
    RewriteRule ^(.*)$ http://scrimsnow.com/$1 [R=301,L]

    first. The redirect might be messing it up.

    If that doesn't fix it, try only having

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^wacko.html$ index.php [L]

    in the .htaccess file and see if

    scrimsnow.com/wacko.html

    works. That'll tell you if you can change the URLs of files.
     
    Nintendo, Apr 4, 2007 IP
  5. bLaZ3n

    bLaZ3n Banned

    Messages:
    259
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    scrimsnow.com/wacko.html

    did work, what does that mean?
     
    bLaZ3n, Apr 5, 2007 IP
  6. abdussamad

    abdussamad Active Member

    Messages:
    543
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Just to make sure you want people accessing xy.com/index/ to get xy.com/index.php transparently right? Try this:
    
    
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index/$ index.php?$1 [R,NC,L]
    
    Code (markup):
     
    abdussamad, Apr 5, 2007 IP
  7. bLaZ3n

    bLaZ3n Banned

    Messages:
    259
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    that didn't work, Idk why this isn't working.. Do I have to have any other attributes? Do my pages before have to be like index.php?id=index?
     
    bLaZ3n, Apr 5, 2007 IP
  8. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I know it doesn't help your current problem but as Nintendo said, you will need to move the "Force non-www" lines above the other rules. If your current rules were working, it would first rewrite /index/ to /index.php, then redirect that request to the non-www domain. It would send a request for www.scrimsnow.com/index/ to scrimsnow.com/index.php, which isn't what you want. But because of the other issue, currently the "force non-www" appears to be working fine.

    All I can suggest is 'prodding' the code till it works. Have you tried it without the trailing slash? What about without forcing the end with $? With a bit of trial and error, you may be able to determine where the problem is - for some reason the rewriterules are not being applied, and you would think that would be because the pattern does not match the request.

    But the code you posted is correct and should work, so I doubt anyone will be able to give you a magic solution, unfortunately.
     
    rodney88, Apr 5, 2007 IP
Thread Status:
Not open for further replies.