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 - 16 through 30 (of 46 total)
  • Author
    Posts
  • #86921
    Gwidaz
    Member

    No i just added this:

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

    And if im adding your code below too its not changing anything..But i have still same problem,because i got added another page folder in url then i click again on same link…

    #86922
    chrisburton
    Participant

    No, you would have to remove the old one and insert the other. Where is your .htaccess file located?

    #86924
    Gwidaz
    Member

    In page folder where is about.php file

    #86925
    Gwidaz
    Member

    Btw i would use this code:

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

    Because that sets for all files inside folder not just for about.php..So that means i dont need to add a lot line

    #86930
    chrisburton
    Participant

    yeah, all that does is remove the .php file extension

    #86935
    Gwidaz
    Member

    Thats right.. but i still dont get it why then im pressing again on about.php link im getting another page link on my url like:

    myweb.com/page/page/about

    Omg..that codding is just madness! :D

    #86936
    chrisburton
    Participant

    @Gwidaz – Alright here’s the fix. Add this to your .htaccess file in the root directory:

    RewriteEngine On
    RewriteRule ^about(/?)$ /page/about.php [NC,L]

    I tested this myself and it works.

    Example:
    /page/about.php

    Say you have 5 pages
    – home.php
    – about.php
    – portfolio.php
    – shop.php
    – contact.php
    and you want them to direct to site.com/home, etc.

    Add this:

    RewriteEngine On
    RewriteRule ^home(/?)$ /page/home.php [NC,L]
    RewriteRule ^about(/?)$ /page/about.php [NC,L]
    RewriteRule ^portfolio(/?)$ /page/portfolio.php [NC,L]
    RewriteRule ^shop(/?)$ /page/shop.php [NC,L]
    RewriteRule ^contact(/?)$ /page/contact.php [NC,L]

    #86938
    Gwidaz
    Member

    Thanks for your time man,but you misunderstand me..

    Thats right..these files redirect to another folder..

    But all i want to do is hide .php for all my files..thats it.. so code

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

    is perfect for that..but only mistage is about adding another page folder if i will click twice same about.php link..

    So if i adding that code in my htaccess it hides my .php and everythink is allright,but i thought would be good if it would hide and page folder too and just display

    myweb.com/about

    instead of

    myweb.com/pages/about

    Plus im working on how to make “/” in the end of about … for exaple

    myweb.com/pages/about/

    or

    myweb.com/about/

    Its seems ok this code :

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

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule (.*)$ /$1/ [R=301,L]

    but after im putting it in my htaccess all design not working..looks like cant read my css file ;)

    #86939
    chrisburton
    Participant

    @Gwidaz – I have no idea what you just said and I’m confused. I thought you said you did want the directory removed?

    You want: sitename.com/pages/about

    You don’t want: sitename.com/about

    Correct?

    #86951
    Gwidaz
    Member

    What i need to do is like you say is move directory,but stay with same file,becauese if i will use this code

    RewriteEngine On
    RewriteRule ^about(/?)$ /page/about.php [NC,L]

    Im getting error “Object not found!” because url become like :

    localhost/about

    and this folder about is not existing in my root directory..

    I dont know do you understand anywai,but i mean i need that if user press link with about.php he will see all information in this file but url become like myweb.com/about

    Still Confused? :D

    #86965
    chrisburton
    Participant

    Yeah, because you’re not telling me specifically what you want. Honestly, I feel like we’re revisiting the above in a circle. First, you just want to remove the .php then I gave a suggestion to keep the file in its place but make it look like sitename.com/about, you said you wanted that. I gave you the answer and now it’s not what you want.

    I realize you want about.php inside the page folder. That’s fine.

    Pick an option, please.

    1. sitename.com/about – keeping about.php inside the page folder

    2. sitename.com/page/about – keeping about.php inside the page folder

    #86968
    Gwidaz
    Member

    First is what im looking for,but then i tryed to enter your code into htaccess im getting error..

    #86970
    chrisburton
    Participant

    Where is the .htaccess file located?

    #86971
    Gwidaz
    Member

    in page folder,where all about,faq… is located

    #86972
    chrisburton
    Participant

    https://css-tricks.com/forums/discussion/comment/53269#Comment_53269

    I said above to put the .htaccess file in the root directory

Viewing 15 posts - 16 through 30 (of 46 total)
  • The forum ‘Other’ is closed to new topics and replies.