View Full Version : le htaccess
wsg14
06-11-2008, 11:26 PM
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
That takes off the .php from filenames, so it is now www.site.com/index how can I make it so it's www.site.com/site/index
wsg14
07-11-2008, 12:06 AM
Sorry for the bump, but this is urgent. ^_^
Iszak
07-11-2008, 01:29 AM
Personally what I think you should do is rewrite all urls to one point of entry e.g. index.php and from there find if the page requested exists and if it doesn't give them a nice error.
But onto what you wanted, if you want to rewrite only urls that are in the form of /site/file to file.php then this is what you want
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^site/([^/\.]+)/?$ $1.php
This will rewrite the urls as stated with the optional trailing slash but this will not rewrite urls in the form of /site/folder/file to folder/file.php, if this is what you want you can use the following.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^site/(.*?)$ $1.php
This will rewrite urls in the form of /site/folder/file or /site/folder/subfolder/file etc to folder/file.php or folder/subfolder/file.php. You can also add your follow sym links or what not.
Enjoy!
wsg14
07-11-2008, 03:52 AM
Thanks a lot. +rep
Cushioned
07-11-2008, 05:31 AM
Personally what I think you should do is rewrite all urls to one point of entry e.g. index.php and from there find if the page requested exists and if it doesn't give them a nice error.
But onto what you wanted, if you want to rewrite only urls that are in the form of /site/file to file.php then this is what you want
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^site/([^/\.]+)/?$ $1.php
This will rewrite the urls as stated with the optional trailing slash but this will not rewrite urls in the form of /site/folder/file to folder/file.php, if this is what you want you can use the following.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^site/(.*?)$ $1.php
This will rewrite urls in the form of /site/folder/file or /site/folder/subfolder/file etc to folder/file.php or folder/subfolder/file.php. You can also add your follow sym links or what not.
Enjoy!
Haha. You always post such long, well explained, & helpful posts. +REP
EDIT: Gotta spread, soz :P
Iszak
07-11-2008, 05:54 AM
It saves the person who was misinformed on my behalf from posting another message and waiting hours to days for another reply. So I post a lengthy one that will be sure to satisfy their needs. Thanks for the rep+ both of you.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.