1

Basically I'm a .net developer so I have no clue regarding this.

I have purchased a php script[site] and configured it over http://spicyindia.net/

eveything works fine when I append php to the file extension.

for eg works fine

http://spicyindia.net/all.php

but

http://spicyindia.net/all

fails

by some RND which I did there is a file named .htaccess which is responsible for this operations..

I have that file uploaded into hosting server too.

can some one tell me if there is any extra configuration which is needed for the same.

some lines in .htaccess .

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteBase /
RewriteRule ^login$ login.php
RewriteRule ^logout$ logout.php

any help would be appreciated.

anubhava
  • 761,203
  • 64
  • 569
  • 643
Manish
  • 1,246
  • 3
  • 14
  • 26
  • @hakre RND was to find out where why files are working with extension and not working without extension , as I'm totally new to PHP but I have .net experience I could lead to possibility of .htaccess file behind this. – Manish Sep 29 '13 at 05:55
  • And your programming question is? If you know nothing about this, why don't you first read about the topic? Otherwise your question might sound more like guessing than asking a programming question. No offence please, but the help section gives some good hints how to improve questions. – hakre Sep 29 '13 at 05:59
  • 1
    @hakre there is no need of being so rude, why do you think I have not read it it forums, its because stack overflow is a good place where you get really good answers which we can trust, I have come here to ask it, and please search stack overflow where people have enjoyed asking very very basic questions..you might be good at PHP.. but not everyone is, I'm just trying to seek help from people who are willing to offer it, if you dont want to help, just dont.. – Manish Sep 29 '13 at 06:07
  • Please use the search then if basic questions is what you look for, we have many of them already covered: [htaccess is not working on iis](http://stackoverflow.com/q/7688714/367456) - and as written my last comment was not ment to be rude, please don't feel offended by my previous comment, as I already wrote in it. – hakre Sep 29 '13 at 06:18

4 Answers4

3

In your .htaccess file, try this to access all,

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Anshad Vattapoyil
  • 23,145
  • 18
  • 84
  • 132
2

It rewrites only login and logout

Try using this one:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

It rewrites every .php file

Sergey Telshevsky
  • 12,077
  • 6
  • 55
  • 78
1

This will convert all www.domain.com/xyz.php to www.domain.com/xyz

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
Moeed Farooqui
  • 3,604
  • 1
  • 18
  • 23
0

If you want to hide .php extension then remove those 2 RewriteRule and have your .htaccess like this:

Options +FollowSymLinks -MultiViews
RewriteEngine On 
RewriteBase /

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}/+\s(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]

Reference: Apache mod_rewrite Introduction

anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I think it's worth if you start to link as well where the manual of Mod Rewrite is and where the regular expressions are documented within it and the the example section in that manual instead of just dumping .htaccess configuration one question after the other not explaining anything. I mean according to your reputation this is long-time overdue. – hakre Sep 29 '13 at 05:51
  • @hakre: Reference doc link added. But too be very honest most of the time new developer doesn't get much help from that reference doc even after going through it multiple times. (btw that link comes as top link in Google search) Besides I had provided proper reasoning and comments in my answer too. Would you really believe that deserved your -1 ? – anubhava Sep 29 '13 at 05:55
  • hi @anubhava I uploaded the file making changes which you have suggested, but still the same issues, what do you think, is it related to IIS? – Manish Sep 29 '13 at 06:14
  • @Manish: Didn't know you're using IIS since it wasn't tagged same. Can you just try last rule in IIS? – anubhava Sep 29 '13 at 06:59