Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,159,012 members, 7,838,537 topics. Date: Friday, 24 May 2024 at 03:24 AM |
Nairaland Forum / Science/Technology / Webmasters / Please Help Me Out With This .htaccess (635 Views)
htaccess / How To Find .htaccess File / Please Who Knows How To Set A 'no Follow' Tag Through Htaccess? (2) (3) (4)
Please Help Me Out With This .htaccess by deco2come: 7:49am On Jul 18, 2011 |
Can someone help to configure this .htaccess well. I want it to remove the file extension. I have succeeded so far but the big issue is that it doesn't work within another folder. E.g it can turn this file "www.domain.com/hello.html to www.domain.com/hello. I have tried many times to make it turn something like "www.domain.com/folder/hello.html to www.domain.com/folder/hello" Although Multiview did the job but it didn't do it perfectly because it doesn't force the extension when a visitor type something like "www.domain.com/hello.html Please modify the below code for me. Here is the .htaccess code #Removing html htm php asp extensions Options +FollowSymlinks RewriteCond %{THE_REQUEST} \ /(.+/)?index(\.html)?(\?.*)?\ [NC] RewriteRule ^(.+/)?index(\.html)?$ /%1 [R=301,L] RewriteCond %{SCRIPT_FILENAME}/ -d RewriteCond %{SCRIPT_FILENAME}.html !-f RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L] RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^(.+)\.html$ /$1 [R=301,L] RewriteCond %{SCRIPT_FILENAME}.html -f RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L] I would also appreciate if you can make it force a slash"/" at the end of each file after removing the extension. Thank you. |
Re: Please Help Me Out With This .htaccess by joomlaman(m): 12:52pm On Jul 18, 2011 |
@ deco2come, Have you tried [size=20pt]changing[/size] .htaccess to htaccess.txt [size=20pt]or[/size] htaccess.txt to .htaccess And make sure your URL friendly mode is enabled. Enjoy! |
Re: Please Help Me Out With This .htaccess by farouqzaib: 3:50pm On Jul 18, 2011 |
You don't need that much code to accomplish that. In resolving the filenames, you need to code a front controller which will handle all requests routed to it(say index.php). The controller should then automatically dynamically include the file even if it is not present in the current directory. I can't give u d code for the rewrite rules now. But working with PHP, u only need to manipulate $_SERVER["REQUEST_URI"]. U can google for front controllers. I hope I helped a little. |
Re: Please Help Me Out With This .htaccess by Mobinga: 10:39am On Jul 19, 2011 |
Why dont you just put it in a folder like this. public-html --hello ------index.html Put the index.html file into the hello folder. |
Re: Please Help Me Out With This .htaccess by DualCore1: 11:11am On Jul 19, 2011 |
farouqzaib: There is a security risk in this approach. Remote file inclusion. If this must be used you should put your controllers in switch-cases. |
Re: Please Help Me Out With This .htaccess by deco2come: 4:11am On Jul 20, 2011 |
farouqzaib: Mobinga: A good example of what I mean can been seen in this site "http://www.aratext.com/". Notice that its address bar doesn't include any file extension(e.g asp,php,html,etc). The moment you add any extension to its address for example http://www.aratext.com/pricing.php, it will redirect you to its error page. Please how can I achieve the same thing? |
(1) (Reply)
Directory Submission / Having Problem With My Wordpress Blog / Looking For A Hosting Company In Ph, Rivers State, Nigeria
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14 |