繁体   English   中英

PHP htaccess用wordpress重写规则

[英]PHP htaccess rewrite rules with wordpress

我有一项正在运行的服务,可让我的用户选择自己的URL地址(例如: http : //hsdfhdfghfh.com/theUserURL

现在,我将前端站点放在wordpress上,但保持我的应用程序与之并行运行。

现在针对这个问题,我在htaccess中设置了一个规则以将用户的url转发到他们的页面,但是wordpress也需要相同的规则才能生成漂亮的URL(永久链接)。

这是我的htaccess以及我的代码和wordpress注入的代码。 目前,只有我的重定向有效,如何使它们都可以协同工作? 我可以在获取URL的php文件中添加代码,如果没有任何条目,将其扔给wordpress显示?

这是我的htaccess:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^(.*)$ ./url.php?w=$1

AddDefaultCharset UTF-8

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

这是我处理重定向的php(url.php)文件:

<?php

session_start();

$url_name = $_GET['w'];


include ('init.php');

$result = mysql_query("SELECT * FROM urls WHERE url='$url_name'");  
$num_rows = mysql_num_rows($result);
$query_result = mysql_fetch_assoc($result);

if($num_rows == 0){

    include($theurl.'/404.php');
    exit();
}


$_SESSION['url_id'] = $query_result['url_id'];

?>

..Shows the rest of the page for the user with the specified url_id session...

也许不用显示404.php页面,我可以以某种方式将输入的URL转移到wordpress?

干杯!

在尝试了不同的方法并尝试使用.htaccess进行操作之后,我意识到此过程对于加载时间和服务器超载非常不利。

我最终将Laravel移到了子域:/

除非您真的想将wordpress调整为核心,否则不要尝试将Wordpress和Laravel放在同一个域中。

暂无
暂无

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

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