通过.htaccess更改永久链接

时间:2018-01-17 10:33:15

标签: php .htaccess

我想更改我的固定链接示例www.testing.com/1234/"titlename“而不是www.testing.com/1234/,如何通过.htaccess更改它?以下是我的.htaccess代码

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /clients/ohmynews/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?article/([a-zA-Z0-9_-]+)$ detail.php?did=$1

RewriteRule ^/?([a-zA-Z0-9_-]+)$ listing.php?lid=$1

RewriteRule ^/?search/([a-zA-Z0-9_-]+)$ search.php?keys=$1

DirectoryIndex index.php
ErrorDocument 404 http://wipstage.com/clients/ohmynews/web/
</IfModule>

1 个答案:

答案 0 :(得分:0)

将此行包含在您的htaccess文件中:

RewriteRule ^([0-9]+)/([A-Za-z0-9._-]+)/?$  detail.php?id=$1&title=$2

由于我不知道您的实际运行文件路径,因此请确保将原始运行文件路径放在我的代码中。

或者让我知道你的文件名和位置,我会编辑我的答案。

相关问题