开发者

rewrite .php extension

开发者 https://www.devze.com 2023-02-02 02:41 出处:网络
Please how can I rewrite Could anybody please rewrite this url? http://localhost/display_news_cat.php?news_cat_i开发者_高级运维d=14&p=2

Please how can I rewrite

Could anybody please rewrite this url?

http://localhost/display_news_cat.php?news_cat_i开发者_高级运维d=14&p=2

to

http://localhost/display_news_cat/14/2

Thank you


You can do thtat with a .htaccess file

put this in a .htaccess file and place it in de root of your site apache must have mod-rewrite on

RewriteEngine on
RewriteRule ^news.php news [QSA,L]

try this for all files

RewriteEngine on
RewriteRule ^(a-zA-Z0-9).php $1 [QSA,L]


Assuming you have installed the rewrite module, you could put this in your virtualhost:

RewriteEngine ON
RewriteRule /newsdev/news /newsdev/news.php [L]

Check this site for more information on RewriteRule: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

But I doubt this is the best way. The rewritemodule is usually not the most efficient way to do easy things like these. Depends on what other complex things you want to rewrite.


With mod_rewrite

http://www.easymodrewrite.com/example-extensions

You need to work with the .htaccess file in your site root... you'll have to create one if it's not there.

0

精彩评论

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