根据当前htaccess编写一段php代码作为seo永久链接url

发布于 2024-09-26 05:08:27 字数 542 浏览 0 评论 0原文

下面是一个著名的 .htaccess 示例

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

,据我所知,URL 的结果将是

http://domain.com/about.php will be http://domain.com/about/
http://domain.com/contact.php will be http://domain.com/contact/

示例,我的 URL 是 http://domain.com/page.php?id=1

如何根据上面的 .htaccess 在 PHP 中编写 URL 为 http://domain.com/page-name/ 的代码。

Below is example a famous .htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

What I know here, the result for URL will be

http://domain.com/about.php will be http://domain.com/about/
http://domain.com/contact.php will be http://domain.com/contact/

Example my URL is http://domain.com/page.php?id=1

How to write a code in PHP which the URL will be http://domain.com/page-name/ according to the .htaccess above.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尽揽少女心 2024-10-03 05:08:27
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]*)/$ /page.php?name=$1 [L]

这是您搜索的内容

http://domain.com/testname/ 将被翻译为 http://domain.com/page.php?name=testname

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]*)/$ /page.php?name=$1 [L]

this is what you search for

http://domain.com/testname/ will be translated to http://domain.com/page.php?name=testname

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文