SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2010
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I have to put /index.php to access my site...

    I was messing with the htaccess file today. I have a couple of URL rewrites and then I put some code to close the site down to all users except for my ip address and redirect them to a site down page.

    I have no idea what I did but I cannot access my site through just www.mysite.com.

    I have to put www.mysite.com/index for it to work, otherwise I get a 404.

    Here is my code in my htaccess file.

    Code:
    Options +FollowSymLinks
    
    #landing page url rewrite#
    RewriteRule ^fabtech(\.php|\.html|)$ FabTech.php
    #end landing page rewrite#
    
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !-f
    RewriteRule ^(.*)\.html$ $1.php [NC]
    #RewriteRule ^([^\.]+)$ $1.php [NC,L]
    
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !\.php$
    RewriteRule ^(.*)$ $1.php [NC,L,QSA]
    
    <Files *> 
    Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0" 
    Header set Expires: 0 
    Header set Pragma: no-cache 
    </Files>
    
    # Turn on mod_rewrite
    RewriteEngine On
    # If not your IP address
    RewriteCond %{REMOTE_ADDR} !^98\.103\.33\.82
    # and not the temporary page
    RewriteCond %{REQUEST_URI} !^/maintenance\.php$
    # redirect to temporary page
    RewriteRule /*$ /maintenance.php [L]

  2. #2
    SitePoint Addict
    Join Date
    Aug 2010
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quick background on what I'm trying to achieve with those rewrites.

    I have a URL that looks like this www.mysite.com/ThisPage

    1) I needed to code a rewrite that would allow a user to not have to include .html or .php.
    2) Because the URL has capitalization (The "T" and the "P"), I had to make sure that would work as well.

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

    Aha! A specification!

    Quote Originally Posted by Bades View Post
    Quick background on what I'm trying to achieve with those rewrites.

    I have a URL that looks like this www.mysite.com/ThisPage

    1) I needed to code a rewrite that would allow a user to not have to include .html or .php.
    2) Because the URL has capitalization (The "T" and the "P"), I had to make sure that would work as well.
    Pseudo-code:
    If the {REQUEST_FILENAME}.php exists, redirect to it.
    If the {REQUEST_FILENAME}.html exists, redirect to it.

    Code:
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME}\.php$ -f
    RewriteRule ^([a-zA-Z/]*)$ $1.php [L]
    
    RewriteCond %{REQUEST_FILENAME}\.html$ -f
    RewriteRule ^([a-zA-Z/]*)$ $1.php [L]
    You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too.

    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

  4. #4
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,314
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Bades View Post
    I have to put /index.php to access my site...
    For what it's worth, I copy/pasted your htaccess, and as long as my DirectoryIndex was set to index.php, it worked just fine. There may be something else going on that we haven't seen.

    Quote Originally Posted by Bades View Post
    I have no idea what I did
    It's definitely in your interest to start using a version control system, such as Git. That way you'll always know what you did and can always revert to an earlier version.
    "First make it work. Then make it better."


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
  •