开发者

Automatic URL rewrite in .htaccess

At first I used IIS server for PHP, so I'm new to Apache (Windows platform). I am in some puzzle related with URL rewrite. As in my .htaccess file I use the below code for URL Rewrite.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.aspx$ $1.php [nc]

Now If I browse a .php page with .开发者_JAVA技巧aspx extension, it works well. eg If I browse

www.example.com/guwahati.php => www.example.com/guwahati.aspx (both URL works.)

But I want it automatically. Like if I type www.example.com/guwahati.php, it will automatically convert to www.example.com/guwahati.aspx, is it possible ? also URL rewritting is not working on my localhost. may anyone help me please.


But I want it automatically. Like if I type www.example.com/guwahati.php, it will automatically cconvert to www.example.com/guwahati.aspx, is it possible ?

It is possible, but by using redirect headers, not URL rewrites. Actually you could do an URL rewrite that redirects to a single file that replaces the target extension with aspx and then redirects to it. You may need to enable mod_rewrite in order for it to work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜