字preSS作为后端只有 [英] Wordpress As Backend Only

查看:251
本文介绍了字preSS作为后端只有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,我已完全融入我的话,preSS的帖子到我的网站,但现在我面临着一个两难......我希望我的网址是搜索引擎友好的,例如:

So I have fully integrated my wordpress posts into my site, however now I am facing a dilemma... I want my URL's to be SEO friendly, for example:

我的URL结构的博客帖子是:

My URL structure for a blog post is:

博客-post.php中postid = 1&安培; TYPE = singlePost

blog-post.php?postid=1&type=singlePost

我想的网址改为如下:

/博客/标题-OF-文/

/blog/Title-Of-Article/

当然标题-OF-条将是动态的。那么,如何才能做到这一点。我是一个相当新的codeR和.htaccess仍在pretty的陌生。

Of course "Title-Of-Article" would be dynamic. So how can I accomplish this. I am a fairly new coder and .htaccess is still pretty foreign to me.

我真的需要这方面的帮助,我已经走遍了互联网寻找解决办法,还没有看到使用任何东西,但我可能只是没有寻找正确的事情。谢谢你对任何人谁也解决我的问题。

I really need help with this, I have scoured the internet looking for solutions and have yet to see anything of use but I could just be not looking for the right thing. Thank you to anyone who has a solution to my problem.

很抱歉,如果我不太清楚,这是我第一次在这里发帖的计算器。我只用一句话preSS作为后端管理上我的网站博客节,我有codeD。我把一切都集成的工作,但我需要找出如何使用搜索引擎友好的网址是以我的动态PHP地址:

Sorry if I wasn't clear enough, this is my first time posting here on stackoverflow. I only use wordpress as a backend admin for a blog section on my site that I have coded. I have everything integrated and working but I need to figure out how to use SEO friendly URLS on my dynamic php address:

www.mysite.com/blog-post.php?postid=1&type=singlePost

www.mysite.com/blog-post.php?postid=1&type=singlePost

我希望它看起来是这样的:

(notice how this file is in the base folder, NOT IN /blog/)

I want it to look like this:

www.mysite.com/blog/Title-Of-Article /

www.mysite.com/blog/Title-Of-Article/

让我知道该怎么做, 谢谢

Let me know what to do, Thanks

推荐答案

我猜你要使用的数据在Word preSS显示的帖子不使用Word preSS作为一个前端?请问你为什么要这么做?似乎是一个大量的工作,你可能能够简单的只是把你的Word preSS安装在一个博客的目录。那么你的其他code可在网站根目录下运行。

I'm guessing that you want to use the data in Wordpress to display posts without using Wordpress as a frontend? May I ask why you want to do that? Seems like a lot of work and you may able to simple just put your Wordpress install in a blog directory. Then your other code could run in the web root directory.

但是,如果你真的想要使用Word preSS作为后端设置了永久链接,你可以做到以下几点。

But if you really want to set up permalinks using Wordpress as a backend, you can do the following.

我在你使用的网址类似 /blog/blog-post.php?postid=1&type=singlePost

I'm assuming you're using urls like /blog/blog-post.php?postid=1&type=singlePost

我想我可能是错的,虽然......

I think I may be wrong about that though...

总之,你可以复制默认的Word preSS的.htaccess规则,并把它放在一个名为博客

Anyway, you can just copy the default Wordpress .htaccess rules and put it in a directory named blog

下面是.htaccess文件,但有一个变化。您需要添加的RewriteBase /博客/

Here is the .htaccess file, but with one change. You need to add RewriteBase /blog/

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

现在每个URL中,看起来像 /博客/我的-的文章 /博客/分类/蒸煮/如何烹将被引导到 /blog/index.php

Now every url in that looks like /blog/my-article or /blog/category/cooking/how-to-cook will be directed to /blog/index.php

这意味着你必须移动从博客-post.php中的code到 /blog/index.php

This means you'd have to move your code from blog-post.php to /blog/index.php

现在在的index.php 则可以使用检索实际URL $ _ SERVER ['REQUEST_URI'] 。所以,如果你访问 www.mysite.com/blog/category/cooking/how-to-cook ,你会得到 /博客/分类/烹饪/如何烹

Now in index.php you can retrieve the actually url using $_SERVER['REQUEST_URI']. So if you visited www.mysite.com/blog/category/cooking/how-to-cook, you'd get /blog/category/cooking/how-to-cook.

现在你可以解析URL,以获取文章名称如何到厨师,并用它作为id抓住你的职位 wp_posts 。这将被保存在 post_name 列。

Now you can parse the url to get the article name how-to-cook and use it as the id to grab your posts in wp_posts. This will be saved in post_name column.

这篇关于字preSS作为后端只有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆