how to make domain.com/something ?

Discussion in 'HTML & Website Design' started by anta, Jan 18, 2011.

  1. #1
    I'm a newbie, how to make a website like this:

    domain.com/something, instead of domain.com/something.html or domain.com/something.php or domain.com/something.shmtl

    use .htaccess?
     
    anta, Jan 18, 2011 IP
  2. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #2
    mod_rewrite (if you use Apache webserer). Use the search or Google for more info.
     
    CSM, Jan 18, 2011 IP
  3. anta

    anta Member

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    Digital Goods:
    1
    #3
    Can you give me example? I'm confused .....
    I searched and found redirect bob.html to alice.html. I don't want to redirect to different page though :(
     
    anta, Jan 18, 2011 IP
  4. BreezeTR

    BreezeTR Well-Known Member

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #4
    Open all php files , convert all link from *.php to *.html
    create a .htaccess file

    write in it

    RewriteEngine On
    RewriteRule ^index.html$ index.php
    RewriteRule ^register.html$ register.php
    etc...
     
    BreezeTR, Jan 18, 2011 IP
  5. asdirc

    asdirc Active Member

    Messages:
    275
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    You could use some free CMS and you also could get a better seo for your site, i think that's why you want to change the extension
     
    asdirc, Jan 19, 2011 IP
  6. anta

    anta Member

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    Digital Goods:
    1
    #6
    Thanks man, it works like charm
     
    anta, Jan 19, 2011 IP
  7. Nefertiti

    Nefertiti Peon

    Messages:
    230
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Since you said you're a newbie: /something is a directory, create it first. something.html, something.php etc. are files inside that directory.
    domain.com/something will automatically open the index.html or index.php file in that directory. if you don't have or don't want an "index.ext" file, if you want some other file to open by default, then you have to write it in .htaccess like - "DirectoryIndex otherfilename.ext" (without the quotes)
     
    Last edited: Jan 19, 2011
    Nefertiti, Jan 19, 2011 IP
  8. gerulis

    gerulis Active Member

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #8
    you should use something like
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^(.*)\.htm$ $1.php [NC]
    Code (markup):
     
    gerulis, Jan 19, 2011 IP
  9. FireStorM

    FireStorM Well-Known Member

    Messages:
    2,579
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    175
    #9
    are you using html , php ??? more info needed
     
    FireStorM, Jan 20, 2011 IP
  10. mohamedsafiq

    mohamedsafiq Active Member

    Messages:
    225
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #10
    mohamedsafiq, Jan 20, 2011 IP
  11. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #11
    Same here, he did not ask to rename from html to php or php to html

    And I already said, mod_rewrite is the solution.

    Google for mod_rewrite extensionless
     
    CSM, Jan 20, 2011 IP
  12. anta

    anta Member

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    Digital Goods:
    1
    #12
    That's not what I wanted.
    I wanted to make mysite.com/index.php into mysite.com/index

    For example, i have page called page.php, I wanted to make it to mysite.com/page and there's no folder "page" in my web, if visitors type mysite.com/page, they'll be redirected to page.php, but in their browser bar it's shown as mysite.com/page

    I tried using
    RewriteEngine On
    RewriteRule ^index$ index.php
    Code (markup):
    It worked in my own server, but it didn't work in my web hosting's server, it said the page isn't redirecting properly. Man I'm confused.....:confused:
     
    anta, Jan 21, 2011 IP
  13. BreezeTR

    BreezeTR Well-Known Member

    Messages:
    115
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    105
    #13
    Your code worked my web hosting

    RewriteEngine On
    RewriteRule ^index$ index.php
    RewriteRule ^index/$ index.php
     
    BreezeTR, Jan 21, 2011 IP
  14. Kumail

    Kumail Peon

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /

    RewriteRule ^(.*)\.html$ $1.php [R=301,L]
     
    Kumail, Jan 21, 2011 IP
  15. davmillar

    davmillar Peon

    Messages:
    12
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #15
    If you're not sure if there's going to be a trailing slash, use a question mark:

    RewriteRule ^index/?$ index.php

    Also, for the index/main page, I wouldn't use /index - I'd simply use / - the regular web site URL. This trick is best for when you have cases where a directory like that makes sense:

    RewriteRule ^register/?$ regform.php
    or
    RewriteRule ^shoes/?$ store.php?type=5

    ETA: The [R=301] is only necessary when moving a page to a new location. So if you're starting fresh on a site, you don't need it. On the other hand, if you're moving from one URL to another (like blah.com/register to blah.com/signup you'll want to use a 301 redirect.

    RewriteRule ^register/?$ /signup [R=301]
     
    Last edited: Jan 21, 2011
    davmillar, Jan 21, 2011 IP
  16. anta

    anta Member

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    Digital Goods:
    1
    #16
    Thanks guys. I actually wanted to remove the page extension so the visitors can easily type it in their browser because I think domain.com/page is better than domain.com/page.php
     
    anta, Jan 22, 2011 IP