SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)

    quick simple question about rewrite

    Code:
    # Rewrite index.html to folder
    RewriteRule ^(.*/)?index\.html?$ /$1 [R=301,L]
    
    # Rewrite non-www (non-canonical) to www
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]
    In the above code the question mark after the html says it can read htm too correct? What about the dollar sign? And if I wanted to make it universal for php ext too how would it look? I could fudge it but I don't know if the $ sign needs to stay for both and etc. Thanks!

    So should it look exactly like this...

    Code:
    ?index\.(html?|php)$

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,273
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PicnicTutorials View Post
    In the above code the question mark after the html says it can read htm too correct?
    Correct.


    Quote Originally Posted by PicnicTutorials View Post
    What about the dollar sign?
    $ matches the end of the string, so that there can't be any other characters in the string after index.html.

    Quote Originally Posted by PicnicTutorials View Post
    And if I wanted to make it universal for php ext too how would it look? ... So should it look exactly like this...

    Code:
    ?index\.(html?|php)$
    Yup!
    "First make it work. Then make it better."

  3. #3
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the validation Jeff!


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
  •