0

I have a folder E:\wamp\www\world_appeal
with admin panel E:\wamp\www\world_appeal\admin

I want htaccess grammar that hide php extension for all the files of front and admin panel as well. How?

1
  • Before you say a solution is not working: .htaccess can only change which links work. I doesn't change your document, so you still need to edit the links in your document from <a href="something.php"> to <a href="something"> Commented Feb 6, 2014 at 7:27

4 Answers 4

1

Place these 2 rules as very first rule in /world_appeal/.htaccess:

RewriteEngine on RewriteBase /world_appeal/ RewriteCond %{THE_REQUEST} /world_appeal/(.+?)\.php[\s?] [NC] RewriteRule ^ %1 [R=301,L,NE] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/world_appeal/$1.php -f RewriteRule ^(.+?)/?$ $1.php [L] 
Sign up to request clarification or add additional context in comments.

1 Comment

after little bit modifying ur code its fine now. in front and admin as well. thank you very much brother. you made my day.
0
RewriteEngine On RewriteCond %{THE_REQUEST} \ /+([^\ \?]+)\.php RewriteRule ^ /%1 [L,R] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.php -f RewriteRule ^(.+)$ /$1.php [L] 

Comments

0

put in .htaccess in each folder

# Turn on the rewrite engine RewriteEngine on # If the request doesn't end in .php (Case insensitive) continue processing rules RewriteCond %{REQUEST_URI} !\.php$ [NC] # If the request doesn't end in a slash continue processing the rules RewriteCond %{REQUEST_URI} [^/]$ # Rewrite the request with a .php extension. L means this is the 'Last' rule RewriteRule ^(.*)$ $1.php [L] 

Comments

0

Instead of using a rewrite for this, you can use the built-in functionality called MultiViews. Simply add just the following line to your .htaccess. This will (among other things) negotiate a suitable file extension if you omit it.

Options +MultiViews 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.