字preSS定制的mod_rewrite - totalnoob?(Wordpress custom mod_rewrite - totalnoob)

   IT问题网   2018-12-07 00:00:00

问 题

我试图让我的字press安装一个定制的mod_rewrite规则,我已经有了一个自定义规则为我的网页结构,我想preserve。

新的自定义规则,我想提出的是,每当有像得到变量:www.mysite.com / 简介 = 用户名

我想使它看起来像:www.mysite.com/username

这是我目前的.htaccess文件:

 #begin字press
 ifmodule mod_rewrite.c
rewriteengine叙述上
的rewritebase /
重写规则^指数\ .php $-[l]
的rewritecond%{} request_filename!-f
的rewritecond%{} request_filename!-d
重写规则。的index.php [l]
 / ifmodule
#结束字press
 

我看着php.net以及有关一般国防部重写很多教程,并专门为字press,但它的一切只是想直接在我的头上,我不明白。 如果任何人都可以给我一些帮助,以获得一些进展有了这个,我真的很ap preciate,我真的想要得到我的头周围的mod_rewrite。

我假设我需要建立一个新的重写规则,但这是,据我得到的。

谢谢 弗兰克

解决方案

完成你想要完成的任务是困难的,至少可以这样说。它需要一个额外的php文件解析传入的请求,因为的.htaccess没有办法知道,如果该url的用户名部分实际上是一个用户名或没有。

该php文件我提到将加载用户表从数据库和比较$ _get ['个人资料']的项,并于比赛,重写/?轮廓= username

如果没有匹配的,它只是传递到index.php文件。

不过,还有一个更简单的解决方案在这里,其中preserves很多你想要的:

 重写规则^配置文件/([^ /] +)$?简介= $ 1 [l]
 

这样做是重写从/型材/ 用户名导入/?配置= 用户名

这不正是你要找的,但它更容易实现。该规则应直接去下面重写规则^指数\ .php $-[l] 在.htaccess文件

如果您有任何问题,我很乐意解释一切都发生在这里。

标签:定制



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

我怎样才能让我的网址,从这个例子中友好吗?(How can I make my urls friendly from this example)

problem my site currently displays like this (when clicki ...

htaccess的问题强制SSL(.htaccess issue to force SSL)

problem i activated ssl on one of my sites (based on word ...

IfModule不会出现是工作?(IfModule doesn't appear to be working)

problem if i use this: lt;ifmodule mod_rewrite.cgt; rewr ...

我怎样才能利用外界信息的URL重写?(How can I get use outside information in url rewrites)

problem hopefully some of you .htaccess gurus can help me ...

基于URL到一个新的页面的RewriteCond重写规则进行的.htaccess,定期EX pression(RewriteCond RewriteRule for .htaccess based on URL to a new page, regular expression)

problem i have an interesting rewriterule and i am not su ...

的.htaccess,mod_rewrite的,正则表达式用目录和文件类型(.htaccess, mod_rewrite, regex with directory and filetype)

problem i want to do a rewrite with the following conditi ...

.htaccess的语言重定向310错误(Htaccess language Redirect 310 error)

problem i have a two language site swedish sidewww.site ...

重定向一切的index.php(Redirection everything to index.php)

problem i wan't to redirect everything to index.php exepe ...

生成SE友好的URL的.htaccess国防部重写(Generating SE friendly URL .htaccess mod rewrite)

problem i've a url which get file name through get method ...

htaccess的子域名重定向(htaccess subdomain redirect)

problem i've searched around and tried a few ...

UrlRewrite 3 GET请求(UrlRewrite with 3 get request)

problem i'm working on a project and stuck on urlrewrite. ...

mod_rewrite的:恶意重定向(Mod_ReWrite: Unwanted redirect)

problem possible duplicate: .htaccess, clean ...

限制用户子目录(limiting users to subdirectories)

problem i have a subdirectory of users that i want to lim ...

重定向子文件夹的.htaccess(Redirection Subfolder Htaccess)

problem i want a redirect using htaccess i have a post na ...

使用的.htaccess,从来没有表现出的index.php(Using .htaccess, never show index.php)

problem how can i never show index.phpfor example, all re ...

在子域的内部服务器错误(internal server error in subdomains)

problem i installed worpress to my main domain abcd.com. ...

基于用户代理手机网站重定向(Mobile website redirection based on user agent)

problem say i've got two distinct domains: ...

的Joomla htaccess的不工作(Joomla htaccess not working)

problem i am using joomla 1.7 and using joomla's built in ...

扩大友好的URL,国防部重写(Expanding friendly url, mod rewrite)

problem i am using modx, which is a cms system. it has a ...

共享主机Zend的项目?(zend project on shared hosting )

problem i created a zend project on localhost on ubuntu o ...