- This topic is empty.
-
AuthorPosts
-
September 10, 2011 at 7:33 pm #86921
Gwidaz
MemberNo 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…
September 10, 2011 at 7:36 pm #86922chrisburton
ParticipantNo, you would have to remove the old one and insert the other. Where is your .htaccess file located?
September 10, 2011 at 7:41 pm #86924Gwidaz
MemberIn page folder where is about.php file
September 10, 2011 at 7:45 pm #86925Gwidaz
MemberBtw 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
September 10, 2011 at 7:59 pm #86930chrisburton
Participantyeah, all that does is remove the .php file extension
September 10, 2011 at 8:11 pm #86935Gwidaz
MemberThats 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
September 10, 2011 at 8:39 pm #86936chrisburton
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.phpSay 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]September 10, 2011 at 10:21 pm #86938Gwidaz
MemberThanks 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 ;)
September 10, 2011 at 10:36 pm #86939chrisburton
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?
September 11, 2011 at 7:16 am #86951Gwidaz
MemberWhat 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
September 11, 2011 at 2:21 pm #86965chrisburton
ParticipantYeah, 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
September 11, 2011 at 3:01 pm #86968Gwidaz
MemberFirst is what im looking for,but then i tryed to enter your code into htaccess im getting error..
September 11, 2011 at 3:06 pm #86970chrisburton
ParticipantWhere is the .htaccess file located?
September 11, 2011 at 3:12 pm #86971Gwidaz
Memberin page folder,where all about,faq… is located
September 11, 2011 at 3:14 pm #86972chrisburton
Participanthttps://css-tricks.com/forums/discussion/comment/53269#Comment_53269
I said above to put the .htaccess file in the root directory
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.
