开发者

MOD_REWRITE /foo.html to /existing/page/?page=foo

开发者 https://www.devze.com 2023-03-08 04:07 出处:网络
Would that be possible? Longer version.. We have a Word Press site but what we want to do is capture certain URLs (eg: /foo/bar-ace-spades.html) and send them to another page in wordpress (eg: /info

Would that be possible?

Longer version..

We have a Word Press site but what we want to do is capture certain URLs (eg: /foo/bar-ace-spades.html) and send them to another page in wordpress (eg: /info/deck-of-cards/), which will then do it's wordpress thing to display the appropriate page.

What I have now is the following:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^foo/(.*)\.html info/deck-of-cards/?page=$1 [NC,L] 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !.*.(?:gif|jpg|png|pdf|mp3|avi|mpeg|bmp|mov)
RewriteRule . /index.php [L]

Now, when I change the following:

RewriteRule ^foo/(.*)\.html info/deck-of-cards/?page=$1 [NC,L]

to

RewriteRule ^foo/(.*)\.html test.php?$1 [NC,L]

it will work.

Unless there is a plugin for Wor开发者_开发技巧d Press that does this, having said that it needs to do exactly what I have described. I've looked at a few SEO plugins. I know there's the SEF plugin for Joomla!, can't find one for Word Press.

Any help or info would be greatly appreciated.

Cheers

ps. I should have been more clear, my client does not want to do a 301 or 302 redirect. Needs to be a rewrite. Tricky problem.

Also added.. When the re write happens, I don't want to display any of that trailing crap. Just need it in the background so /foo/test-page.html > /info/deck-of-cards/ will be displayed, and the Requests hidden. Then I can get into PHP and get the gets.

It's a nightmare.


This plugin should fulfill your need

https://wordpress.org/extend/plugins/redirection/


In that case, you may want to pass the argument to the index.php to specified the page/post you want.

RewriteRule ^foo/(.*)\.html index.php?p=xxx&page=$1 [NC,L] 

After that, you should have disabled the auto url correction feature in Wordpress, follow the instruction here

http://www.mydigitallife.info/how-to-disable-wordpress-canonical-url-or-permalink-auto-redirect/

Hope this help :)

added: I found that these 2 steps isn't enough for this case, the title come but not the content.

0

精彩评论

暂无评论...
验证码 换一张
取 消