htaccess rewrite remove file extension?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • acctman
    Confirmed User
    • Oct 2003
    • 2840

    #1

    htaccess rewrite remove file extension?

    anyone have an example of how to write url file extension

    specific rewrite...
    http://www.site.com/members.html to http://www.site.com/main

    and then remove all extension for all files ending in *.html
    http://www.site.com/*.html to http://www.site.com/*

    also this needs to work with and without www

    my current htaccess
    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On		
    RewriteCond %{HTTP_HOST} ^(ssss\.com)$ [NC] 
    RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteCond %{HTTP_HOST} !^(www\.)?ssss\.com$ [NC] 
    RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.ssss\.com$ [NC] 
    RewriteRule ^(.*)$ http://www.ssss.com/view/%2.html [R=301,L]
    RewriteCond %{REQUEST_URI} !^files/
    RewriteCond %{REQUEST_FILENAME}  !-d
    RewriteCond %{REQUEST_FILENAME}  !-f
    RewriteRule ^(.*) index.php [L]
    </IfModule>
    Last edited by acctman; 10-07-2011, 11:35 PM.
  • fris
    I have to go potty
    • Aug 2002
    • 56002

    #2
    Originally posted by acctman
    anyone have an example of how to write url file extension

    specific rewrite...
    http://www.site.com/members.html to http://www.site.com/main

    and then remove all extension for all files ending in *.html
    http://www.site.com/*.html to http://www.site.com/*

    also this needs to work with and without www

    my current htaccess
    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On		
    RewriteCond %{HTTP_HOST} ^(ssss\.com)$ [NC] 
    RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
    RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
    RewriteCond %{HTTP_HOST} !^(www\.)?ssss\.com$ [NC] 
    RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.ssss\.com$ [NC] 
    RewriteRule ^(.*)$ http://www.ssss.com/view/%2.html [R=301,L]
    RewriteCond %{REQUEST_URI} !^files/
    RewriteCond %{REQUEST_FILENAME}  !-d
    RewriteCond %{REQUEST_FILENAME}  !-f
    RewriteRule ^(.*) index.php [L]
    </IfModule>
    need more descriptive what you want.

    but here is the basis


    Options +FollowSymLinks
    RewriteEngine On

    # which do you want?

    # make /members.html use /main
    RewriteRule ^members.html /main [NC]

    # make /main use /members.html
    RewriteRule ^main /members.html [NC]

    # alias /filename.html to /filename (dont know if you want to redirect the .html to the non or just make it work without

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.+)$ $1.html [L,QSA]
    hope this helps you out somewhat.
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


    Only Fans Data

    20+ Custom Adult Themes and Plugins

    Comment

    • acctman
      Confirmed User
      • Oct 2003
      • 2840

      #3
      Originally posted by fris
      need more descriptive what you want.

      but here is the basis




      hope this helps you out somewhat.
      /members.html use /main is exactly what I wanted. not sure which to use for the next part where I want all urls with .html to have the alias of there filename ... whatever.html would be /whatever

      Comment

      • fris
        I have to go potty
        • Aug 2002
        • 56002

        #4
        that will work then, i used to use something like that for arylia, since tgps didnt like .php files being submitted, i aliased .html to .php
        Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


        Only Fans Data

        20+ Custom Adult Themes and Plugins

        Comment

        • acctman
          Confirmed User
          • Oct 2003
          • 2840

          #5
          Originally posted by fris
          that will work then, i used to use something like that for arylia, since tgps didnt like .php files being submitted, i aliased .html to .php
          thanks. how did you become so good with htaccess mod_rewrites?

          Comment

          • georgeyw
            58008 53773
            • Jul 2005
            • 9865

            #6
            Originally posted by acctman
            thanks. how did you become so good with htaccess mod_rewrites?


            http://www.generateit.net/mod-rewrite/
            TripleXPrint on Megan Fox
            "I would STILL suck her pussy until her face caved in. And then blow her up and do it again!"

            Comment

            • fris
              I have to go potty
              • Aug 2002
              • 56002

              #7
              Originally posted by georgeyw
              never found a generator to do many of the stuff I do

              Code:
              # enables domain.com/search/search-term.html 
              
              Options +FollowSymLinks
              RewriteEngine On
              RewriteRule ^search/(.+)\.html$ /index.php?s=$1 [QSA,L]
              Code:
              # make /pics/askj12.jpg work as /askj12.jpg
              
              Options +FollowSymLinks
              RewriteEngine On
              RewriteCond %{DOCUMENT_ROOT}/data%{REQUEST_URI} -f [OR]
              RewriteCond %{DOCUMENT_ROOT}/data%{REQUEST_URI} -d
              RewriteRule !^pics(/.*)?$ /pics%{REQUEST_URI} [QSA,L]
              Code:
              # from: http://www.example.com/profile.php?user=username 
              # to: http://username.example.com 
              
              Options +FollowSymLinks
              RewriteEngine On
              RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
              RewriteRule .* - [L]
              RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
              RewriteRule ^$ /profile.php?user=%1 [QSA,L]
              Code:
              # rewrite rules to generate on the fly
              
              # /sub/evil.domain.com/pics --> http://evil.domain.com/pics
              # /sub/content.domain2.com/clicks --> http://content.domain2.com/clicks
              # /sub/ab.domain3.com/moo --> http://ab.domain3.com/moo
              
              Options +FollowSymLinks
              RewriteEngine On
              RewriteCond %{HTTP_HOST} !^(www\.)?[^\.]+\.[^\.]+$ [NC]
              RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+\.[^\.]+\.[^\.]+)$ [NC]
              RewriteCond %{DOCUMENT_ROOT}/sub/%2%{REQUEST_URI}/ -d
              RewriteRule [^/]$ http://%2%{REQUEST_URI}/ [R=301,L]
              RewriteCond %{HTTP_HOST} ^(.*\.)([^\.]+\.[^\.]+\.[^\.]+)$ [NC]
              RewriteRule ^(.*)$ http://%2/$1 [R=301,L]
              RewriteCond %{HTTP_HOST} !^(www\.)?[^\.]+\.[^\.]+$ [NC]
              RewriteCond %{HTTP_HOST} ^([^\.]+\.[^\.]+\.[^\.]+)$ [NC]
              RewriteCond %1:::%{REQUEST_URI} !^(.+):::/sub/\1(/.*)?$ [NC]
              RewriteCond %{DOCUMENT_ROOT}/sub/%1/ -d
              RewriteRule ^(.*)$ /sub/%1/$1 [QSA,L]
              Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


              Only Fans Data

              20+ Custom Adult Themes and Plugins

              Comment

              Working...