RewriteEngine On
RewriteBase /
# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
And would that just remove the .php... I got it off of another site.
Also it there a way to make it so that if the files in a folder are requsted by site.com it returns a 404 error page and then if its requsted by the site domain.com. it allows it. See I am hosted by ipower and I have a domain pointer to my public html folder and then to a folder. I want it to be sot that when I am on the regular site you can't get to the folder, but when I am on the pointed domain it shows up everything.
OK I found to put it in .htaccess file, but I am having a problem if I go to site.com/folder/index.php it sends me to site.com/... and when I got to site.com/folder/dir/dir/file.php nothing comes up at all... help!
Put the .htaccess file in the folder that you want to be affected by it.
You can send any request to your .htaccess file and return a 403. You will need to know which files and enter them by name or use some regex matching on file types.
I put that in the .taccess file and I am gettin so manyproblems... If I go to /index.php i get errors, and i just can't get anythign to work. And if i go to /folder/dir/folder/file.php i get and error as well as folder/dir/folder/file
I was just looking... none of your rewrite rules are going to work because they have no opening delimiter (^). Have you looked at the mod_rewrite cheat sheet in the Apache, IIS and Servers forum?
I want to remove .php for the URL the user sees but where in the codes I still can call something.php and link to something.php.
If its possible I want to be able to do this:
I have a shared hosted domain, site.com. I also have a domain, example.com domain pointed to site.com/folder. I want to make it so that if someone goes to site.com/folder it returns a 404 error. If they go to example.com it doesn't do anything and it allows them to view the pages.
tecktalkcm0391 wrote:If its possible I want to be able to do this:
I have a shared hosted domain, site.com. I also have a domain, example.com domain pointed to site.com/folder. I want to make it so that if someone goes to site.com/folder it returns a 404 error. If they go to example.com it doesn't do anything and it allows them to view the pages.
The challenge is that if you lock site.com/folder down and return a 403 forbidden, then pointing example.com to it will return the same 403 forbidden. Doesn't that kind of defeat the purpose?
Yeah, I think you can do it that way, but I think the Allow From directive will then take precedent, meaning that if the referer is not THAT domain, your page won't load. I could be way wrong on this though.
As for the dropping of the .php extension, mod_rewrite can do that easily. Essentially you tell your .htaccess file to take a certain pattern and transform that pattern behind the scenes to your actual pages.
And nothing seems to be working I keep getting the 404 error when I got to site.com/dir/index instead of index.php if i go to index.php it still displays index.php.
Sorry if I am being a pain but I can't seem to figure this out!
RewriteEngine on
RewriteRule ^us/([A-Z]+)$ us.php?state=$1 [nocase]
I want that to take anything that is us.php?state=[State] and convert it to us/[State]
how come when I go the the us.php?state=$1 it stays the same?
mod_rewrite does not work that way. If you type in site.com/us/[State] where State is the name of a state, then it would look like the clean URL but would actually load site.com/us.php?state=[State]