.htaccess help needed - turning /xxx.php to /xxx

Discussion in 'Apache' started by pixeldawn, Mar 23, 2007.

Thread Status:
Not open for further replies.
  1. #1
    pixeldawn, Mar 23, 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.$2 [L]
     
    Nintendo, Mar 23, 2007 IP
    Geraldm likes this.
  3. Geraldm

    Geraldm Well-Known Member

    Messages:
    1,330
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    115
    #3
    That would do it for everything right? How can you do it for only one specific php file??

    Cheers ...
    Gerald.
     
    Geraldm, Mar 24, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Replace the regex with the filename you want to rewrite:
    RewriteEngine on
    RewriteRule ^xxx$ xxx.php [L]
    Code (markup):
     
    rodney88, Mar 24, 2007 IP
  5. Geraldm

    Geraldm Well-Known Member

    Messages:
    1,330
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    115
    #5
    Hmm,

    It's not working.....

    I'm using phpLD3.1 and I am trying to redirect anyone going to <url>/<specificfolder>/ to <url>/filename.php

    When putting your code into the .htaccess file to does not redirect to <url>/filename.php

    Any ideas?

    Thanks,
    Gerald.
     
    Geraldm, Mar 24, 2007 IP
  6. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What's in the rest of the .htaccess file?
    Do you want a redirect or a rewrite?
    Try using ^xxx/?$ as the pattern to match xxx with a trailing slash.
     
    rodney88, Mar 24, 2007 IP
    Geraldm likes this.
  7. Geraldm

    Geraldm Well-Known Member

    Messages:
    1,330
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    115
    #7
    Here is the .htaccess file:

    
    #################################################
    ## PHP Link Directory - Apache Server Settings ##
    #################################################
    
    # Protect files
    <Files ~ "^(.*)\.(inc|inc\.php|tpl|sql)$">
      Order deny,allow
      Deny from all
    </Files>
    
    # Protect directories
    <Files ~ "^(backup|files|images|include|lang|libs(/.+)?|temp(/.+)?|templates(/.+)?|javascripts(/.+)?)$">
      Order deny,allow
      Deny from all
    </Files>
    
    # Disable directory browsing
    Options -Indexes
    
    # Follow symbolic links in this directory
    Options +FollowSymLinks
    
    # Override PHP settings that cannot be changed at runtime
    # (If your server supports PHP settings via htaccess you can comment following two lines off)
    # php_value register_globals   0
    # php_value session.auto_start 0
    
    # Customized error messages
    # ( If you are running in a subfolder please add it, example: "directory/index.php?httpstatus=404" )
    ErrorDocument 404 index.php?httpstatus=404
    
    # Set the default handler
    DirectoryIndex index.html index.php
    
    # URL rewrite rules
    <IfModule mod_rewrite.c>
       RewriteEngine On
    
       ## Details Link Page Rewrite##
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-l
       RewriteRule (.*)detail/link-(.*).htm[l]?$ detail.php [QSA,NC]
    
       ## Pagination Rewrite
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-l
       RewriteRule (.*)page-(\d+)\.htm[l]?(.*)$  $1/?p=$2 [PT,NC]
    
       ## Category redirect
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-l
       RewriteRule ^(.*)$ index.php [QSA,L]
    
    </IfModule>
    
    Code (markup):
    I've tried putting the following directly under the RewriteEngine On statment:
    RewriteRule ^prupdater$ prupdater.php [L]
    Code (markup):
    Basically I want a rewrite ... i.e. still have the URL as <url>/prupdater/ showing but have that pointing to the <url>/prupdater.php file.

    Cheers ....
    Gerald.


    Edit: Just put this in: RewriteRule ^prupdater/?$ prupdater.php [L] and it works !!! Thanks!!
     
    Geraldm, Mar 24, 2007 IP
  8. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #8
    DarrenC, Mar 24, 2007 IP
Thread Status:
Not open for further replies.