简体   繁体   English

如何在我的子目录 htaccess 文件中编写重写规则以实现此目的

[英]How to Write a rewrite rule in my sub directory htaccess file to achieve this

I have a sub directory named as "apps" under my public html folder.I fetch "apps" database table records and show some of the records on index.php file and give a link to another file to show more records for the particular row.我在我的公共 html 文件夹下有一个名为“apps”的子目录。我获取“apps”数据库表记录并显示 index.php 文件中的一些记录,并提供指向另一个文件的链接以显示特定行的更多记录. I have another file named "details.php" in the same directory where i show full records of selected row.我在显示所选行的完整记录的同一目录中有另一个名为“details.php”的文件。

my link looks like this我的链接看起来像这样

<a href="details.php?
name=APP_NAME">APP NAME 
</a>

where APP_NAME is unique in database table.其中 APP_NAME 在数据库表中是唯一的。

suppose i have an app named "oreo" in my db then the link look like假设我的数据库中有一个名为“oreo”的应用程序,那么链接看起来像

<a href="details.php?
name=oreo">oreo 
</a>

I want rewrite this url to make it seo friendly like this我想重写这个 url 以使其像这样 seo 友好

<a href="oreo">oreo 
</a>

and full url will look like this完整的网址将如下所示

https://example.com/apps/oreo

I have tried this code,but it's not working我试过这个代码,但它不起作用

RewriteRule ^/apps/(.*)$ 
/details.php?name=$1  

I don't have much clarity on Rewrite Rule..So I need help..我对重写规则不太清楚..所以我需要帮助..

got it.It works明白了,有效

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /apps/details.php?name=$1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM