Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other .htaccess url’s

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 46 total)
  • Author
    Posts
  • #34305
    Gwidaz
    Member

    Hi people!

    I was looking everywhere for that problem solving,ofcourse i didnt find anything about that exept redirecting..

    For example i have my localhost page.. i dont wanna show any files after folders.. I solved that problem only with index file by doing this :

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^/]+/)*index.php HTTP/
    RewriteRule ^(([^/]+/)*)index.php$ http://localhost/$1 [R=301,L]

    This code just redirecting outomaticly to main page if somebody enter index.php in the end of url..

    But different problem is with another pages..For example i have page/ folder and inside im keeping about.php,contact.php and etc. And i want that these all files wont be showing after page folder..There is an example :

    localhost/page/about.php

    after

    localhost/page/ <


    How to show only like this,but make that people can see about.php page????

    Please help me,i think that topic would be very useful for everybody..Sorry for my english and if you dont understand what i mean just let me know.. btw you can see what i mean in soundcloud.com website..

    #86901
    chrisburton
    Participant

    @Gwidaz – Wait, so you want site.com/page/about.php to eliminate “about.php”?

    Why not exclude the folder and just have about.php and then use a rewrite to remove the .php?

    Example
    Before: sitename.com/about.php
    After: sitename.com/about

    #86904
    Gwidaz
    Member

    Oh…You see,what i dont wanna do,is keep all files in root derictori..because that will be very confusing.. but i like your idea very mutch! but is that possible to keep all this files separated in pages folder and do what you said?

    Because i will take like example this : http://soundcloud.com/help/community

    How they do that? is that like your idea? Thanks a lot for replying!

    #86905
    chrisburton
    Participant

    @Gwidaz – Yes. But if you do what you want, it will look like sitename.com/page…confusing to the user if they want to link someone to a specific page.

    I recommend sitename.com/page/about at the least.

    My personal opinion, I think the user already knows they are on a page, why would you have to tell them in a folder? The idea is to keep your URL as short as possible.

    Maybe what you could do is strip the directory page/ and file extension .php so it only shows sitename.com/about while still preserving organization that you’re asking.

    #86907
    Gwidaz
    Member

    No,i dont want to tell that for user,i wanna keep that files only in seperated folder,because if i will keep all files in main folder (root) ant i got 60files that will be very confusing to find them that just keep something in folders,like system and etc.. that idea about sitename.com/page/about is perfect :)

    #86909
    chrisburton
    Participant

    You’re not understanding what I’m saying.

    Example: Keep your file structure as you have it
    sitename.com/page/about.php

    Remove the bold with .htaccess:
    sitename.com/page//about.php

    So the user will see:
    sitename.com/about

    Anyway, use this snippet and add it to your sub directories

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^.]+)$ $1.php [NC,L]
    #86911
    Gwidaz
    Member

    Ohhh i see now..Sorry about that.. thats what im talking about.. but still same question is how to do that? I was looking in this website about .htaccess tricks but really dont know is there any to make like this..thanks alot mate for your help!

    #86912
    chrisburton
    Participant

    Haha, confused?

    I would go with removing the directory and file extension

    #86914
    chrisburton
    Participant

    Try this instead:

    RewriteEngine on
    RewriteRule ^about(/?)$ /page/about.php [NC,L]
    #86915
    Gwidaz
    Member

    Hmmm.. i tryed your code:


    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^.]+)$ $1.php [NC,L]

    ..but weird think is that i still have .php and i have right now :

    myweb.com/page/page/about.php

    what the hell? :D

    And another question maybe you will know this..Im working on localhost and if i edit .htaccess file i need to clear all my history from browser to see changes..

    #86916
    chrisburton
    Participant

    I’m working on a fix right now.

    #86917
    Gwidaz
    Member

    Thank a lot,but i saw weird problem..then i went to about.php it looks like this

    myweb.com/page/about.php

    and if i will click on footer about again,or faq and etc then i got added another page/ on my link like:

    myweb.com/page/page/about.php

    Hmmm..

    #86918
    chrisburton
    Participant

    Are you using MAMP or WAMP and if so do you have mod_rewrite enabled?

    #86919
    Gwidaz
    Member

    There you go! I found solution..

    Inser your code in your .htaccess file

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^.]+)$ $1.php [NC,L]

    And then link your adress without .php for example

     about

    But im still thinking how hide now page folder :))

    #86920
    chrisburton
    Participant

    Did you try this?

    RewriteEngine on
    RewriteRule ^about(/?)$ /page/about.php [NC,L]
Viewing 15 posts - 1 through 15 (of 46 total)
  • The forum ‘Other’ is closed to new topics and replies.