Help me with htaccess

Discussion in 'PHP' started by gladikarthik, Jan 4, 2010.

  1. #1
    Hi every one...

    i wrote a htaccess script as follows
    RewriteRule (.*) index.php [L]
    Code (markup):
    but it redirect all the requests including css and images.so the css files are not loaded.how to handle the htaccess to allow request to css and image files...

    thanks in advance
     
    gladikarthik, Jan 4, 2010 IP
  2. kosmowariat

    kosmowariat Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    for example :
    
    RewriteRule !\.(js|ico|gif|jp?g|png|css)$ index.php
    
    Code (markup):
     
    kosmowariat, Jan 4, 2010 IP
  3. vinoth.t

    vinoth.t Peon

    Messages:
    156
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Add the below line into your .htaccess file. This line is used to tell the apache that don't redirect for the following extensions
    
    RewriteCond %{REQUEST_URI} !\.php$
    RewriteCond %{REQUEST_URI} !\.gif$
    RewriteCond %{REQUEST_URI} !\.jpg$
    RewriteCond %{REQUEST_URI} !\.png$
    RewriteRule (.*) index.php [L]
    
    Code (markup):
     
    vinoth.t, Jan 4, 2010 IP
  4. gladikarthik

    gladikarthik Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule administrator$ adminlogin.php 
    RewriteRule (.*).html index.php 
    RewriteRule (.*) index.php?action=profile&name=$1 
    RewriteRule !\.(js|ico|gif|jp?g|png|css)$ index.php
    
    Code (markup):
    this is my htaccess file..

    my need is when click on the http://localhost/mysite/signin.html it goes to signin page
    http://localhost/mysite/username will goes to the users profiel page.

    if i use the replied script http://localhost/mysite.signin.html and http://localhost/mysite/username are redirect to the index.php page only..

    help me...thanks..
     
    gladikarthik, Jan 4, 2010 IP
  5. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #5
    use / like

    (or)
    (place on line 2)
     
    olddocks, Jan 4, 2010 IP
  6. gladikarthik

    gladikarthik Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thankyou Friends... finally requirement was solved by this code.....

    
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule administrator$ adminlogin.php [L]
    RewriteRule (.*).html index.php [L]
    
    RewriteCond %{REQUEST_URI} !\.php$
    RewriteCond %{REQUEST_URI} !\.gif$
    RewriteCond %{REQUEST_URI} !\.jp?g$
    RewriteCond %{REQUEST_URI} !\.png$
    RewriteCond %{REQUEST_URI} !\.css$
    RewriteCond %{REQUEST_URI} !\.js$
    RewriteRule ^(.*) index.php?action=profile&name=$1 [L]
    
    Code (markup):
    Thnks to all
     
    gladikarthik, Jan 4, 2010 IP