i am using Apache rewrites in .htaccess file.
RewriteRule ^index\.html$ index.php
when i give URL in the address bar like this: index.html , it is redirected to index.php,displays the content in the browser.
But in the address bar URL changes to index.php instead of index.html.
I can’t understand why it is display like .php instead of .html
Give me the correct approach to solve this problem.
RewriteRule ^index\\.html$ [b]http://www.rfdesign.info/index.php[/b]
Using absolute path (highlighted) in the substitution forces external redirect.
External redirect means that redirect headers are sent to the browser and it requests the new resource (hence the new URL).
Internal redirect (which you want) processes the redirect internally in Apache without the browser even knowing.
Internal redirect can only happen within the same host (for rather obvious reason – local Apache doesn’t have access to other hosts’ resources):
RewriteRule ^index\\.html$ /index.php
phpinfo() so that we can make sure mod_rewrite is enabled.
thank u for replying me.
once u see the site:
give me some suggestions for better performance.
I want to put friendly URL,give me the idea.
This is the code am using in .htaccess file.
RewriteRule ^alice.html$ bob.html
RewriteRule ([a-zA-z_-]+)/([0-9]+)/([^/]+)/$ http://www.rfdesign.info/news_display.php?nid=$1 [NC,L]
RewriteRule ^form\.html$ http://www.rfdesign.info/form-from-scratch/form.php
RewriteRule ^view/(.*)\.html$ http://www.rfdesign.info/form-from-scratch/view.php?id=$1 [QSA]
RewriteRule ^view/([0-9]+)/$ http://www.rfdesign.info/form-from-scratch/view.php?id=$1 [NC,L]
RewriteRule ^index\.html$ http://www.rfdesign.info/index.php
RewriteRule ^home\.html$ http://www.rfdesign.info/index.php
I guess there is something problem with apache itself. Can you show us the full code in your .htaccess that you have so far?
PS: Are you in the correct way of using mod_rewrite? See once this article to start:
and for some examples:
If your mod_rewrite engine is enabled then the following must work without any problem which works just fine in my case:
RewriteRule ^index\\.html$ index.php [L]
RewriteRule ^about\\.html$ about.php [L]
RewriteRule ^(.*?)\\.html$ $1.php [L]
I think it is better to move this thread to ‘Apache Configuration’!