如何使用.htaccess

时间:2018-10-17 07:23:58

标签: php .htaccess

如何删除或隐藏php扩展名?使用.htaccess吗?

2 URL示例:

http://localhost/folder/test.php?id=1&company=ABC&address=AAAAA

http://localhost/folder/test2.php?username=abcd

谢谢

1 个答案:

答案 0 :(得分:1)

Title中将此代码添加为int requestedId = 21803; var requestedTitle = myDbContext.Table1Elements // from all Table1 elements .Where(table1Element => table1Element.Id = requestedId) // keep the one with the requestedId .Select(table1Element = table1Element // and select the Title .Table2Element // of the Table4 element .Table3element // that it belongs to .Table4Element .Title) .FirstOrDefault(); // You know there is only one int requestedId = 21803; var requestedTitle = myDbContext.Table1Elements // from all Table1Elements .Where(table1Element => table1Element.Id = requestedId) // keep the one with the requestedId .Join(myDbContext.Table2Elements, // join with Table2Elements table1Element => table1Element.Table2ElementId, // from Table1 take the foreign key table2Element => table2Element.Id, // from Table2 take the primary key (table1Element, table2Element) => table2Element) // when they match keep the Table2 .Join(myDbContext.Table3Elements, // to join with Table3 table2Element => table2Element.Table3ElementId, // foreign key to Table3 table3Element => table3Element.Id, // primary key (table2Element, table3Element) => table3Element) // keep table3Element .Join(myDbContext.Table4Elements, // to join with Table4 table3Element => table3Elemen.Table4ElementId, // foreign key table4Element => table4Element.Id, // primary key (table3Element, table4Element) => table4Element.Title) // keep the Title .FirstOrDefault(); // expect only one element 扩展名

.htaccess

对于查询字符串,请添加以下行 试试这个

html

尝试一下

php

尝试一下

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L] //for php extension
RewriteRule ^([^\.]+)$ $1.html [NC,L] //for html extension

我已经添加了所有可能的解决方案