我正在使用修改后的Wordpress网站网址,如下所示: http://test3.ober.com/detail-page/?refid=ahla-clinical-research-practice-guide
我想将网址更改为以下内容: http://test3.ober.com/detail-page/ahla-clinical-research-practice-guide
我应该在.htaccess文件中添加什么重写规则?
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
添加信息:这个Wordpress网站正在使用PHP代码小部件,我们从其他通常不属于Wordpress的MySQL数据库表中提取内容。
if (isset($wp_query->query_vars['refid'])) {
$refid = $wp_query->query_vars['refid'];
$safe_id = mysql_real_escape_string( $refid);
$SQL = "select publication_title, publication_content, publication_date from publications where publication_url_name = '$safe_id'" ;
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
$detail_data = $db_field['publication_content'];
$title = $db_field['publication_title'];
$date = $db_field['publication_date'];
}
mysql_close($db_handle);
$pub_date = date("F d, Y",strtotime($date));
echo "<h1>" . $title . "</h1>";
echo "<span class=\"date\">" . $pub_date . "</span>";
echo $detail_data;
}
我尝试过这样的东西,但它没有用。有什么建议吗?
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{QUERY_STRING} (?:^|&)refid=([^&]+)(?:$|&)
RewriteRule ^detail-page/$ detail-page/%1?
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
答案 0 :(得分:0)
WordPress具有内置的URL重写功能。在WP术语中,这些被称为“永久链接”。您可能正在寻找“帖子名称”选项。