Jump to content

Using titles - rewrite


eevan79

Recommended Posts

I try to integrate WordPress perm links into new cms (custom), so I need to make rewrite condition for old links in posts.

 

 

So I have links like this:

site.com/category/page-title

or

site.com/category/page-title/

 

 

site.com/games/text/page-title

or

site.com/games/text/page-title/

etc.

 

 

I need to get last request uri ( url after last "/" ) and rewrite to:

site.com/index.php?title=page-title

I have tried various methods but nothing do not succeed.

Link to comment
https://forums.phpfreaks.com/topic/237258-using-titles-rewrite/
Share on other sites

I forgot to include code. This is what I have tried (on localhost):

 

 

 

RewriteEngine On
RewriteBase /wp/


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-]+)$ wp/index.php?title=$1 [L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]

 

 

So if i have link like this: http://localhost/wp/test I got: title=test. But if I have more "/" or slash on the end of url I get page with wrong links (including .css etc).

 

 

I just need to get "text" after last trailing slash and rewrite to title=?

  • 2 weeks later...

Because, there are lots of (already) linked articles in other articles.

 

 

However, I solve this and all links from Wordpress are valid (rewrited with title=LINK).

RewriteRule ^([a-zA-Z0-9-]+)$ http://localhost/wp/index.php?title=$1 [L,R=301]

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.