SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot godfather999's Avatar
    Join Date
    Sep 2011
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing www and .php not working

    So I insert following code in my apache.htaccess file in order to remove www and php.

    Whats wrong here?

    This is my whole file

    Code:
    ErrorDocument 500 /500.php
    ErrorDocument 404 /404.php
     
    # force non-www domain
    RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
    RewriteRule (.*) http://example.com/$1 [R=301,L]
     
    #RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ $1.php [QSA,L]

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,148
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    In what way is it not working?

    You type in the URL (...) and you expect (...) to happen, but actually (...) happens.
    "First make it work. Then make it better."

  3. #3
    SitePoint Zealot godfather999's Avatar
    Join Date
    Sep 2011
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I type a URL with www and I want it to not show www even when I type. I want it to be without www. Same thing is with .php which always shows up.

  4. #4
    SitePoint Zealot godfather999's Avatar
    Join Date
    Sep 2011
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Website is running on basic linux server, if that helps.

  5. #5
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,148
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    The problem I'm having is that the code you posted works just fine.... depending on what you're trying to do. Which is why I asked you to clarify, "In what way is it not working?" It's not helpful enough to just say that you "type a URL." Nor is it helpful enough to say, "I want it to be without." You need to show us the specific URL you're typing, and you need to tell us the specific behavior you expect. Are you hoping for an external redirect? That is, the server sends back a redirect response and the browser re-fetches from that new location. This tends to have the effect of changing the URL in the address bar. Or are you hoping for an internal rewrite? That is, you type in an extensionless URL, and the server maps that extensionless path to a real file on your server. This lets you leave .php off the URL but still get the content of the .php page.
    "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
  •