2

To remove .php extension from URL and replaced with .html i have wrote:

Options -Indexes Options -Multiviews Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^(.*)\.php $1.html [QSA,L] 

This work fine and i the extension changed, but i get this message:

Not Found The requested URL /**xxxxxx**.html was not found on this server. 
0

2 Answers 2

1

To serve .php files as .html you can use this code:

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

5 Comments

one more question , im sorry for that , i want to make /xxxx.html?id=19 to /19, how i can do it , I have write RewriteRule ^(\w+)/?$ /xxxx.php?id=$1 [L,QSA] and this in second time RewriteRule ^(\w+)/?$ /xxxx.html?id=$1 [L,QSA] , but it doesn't work
Actual internal URL is /xxxx.html?id=19 OR /xxxx.php?id=19?
the file name in server is /xxxx.php and when i put the script that u give me in answer , the url become /xxxx.html
Hmm this will be big change in these rules which would otherwise be useful for someone looking for .php -> .html template. I would suggest opening a new question so that I can address it separately from this thread.
0

wrong way round? try

RewriteRule ^(.*)\.html $1.php [QSA,L] 

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.