eevan79 Posted May 23, 2011 Share Posted May 23, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/237258-using-titles-rewrite/ Share on other sites More sharing options...
eevan79 Posted May 23, 2011 Author Share Posted May 23, 2011 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=? Quote Link to comment https://forums.phpfreaks.com/topic/237258-using-titles-rewrite/#findComment-1219254 Share on other sites More sharing options...
Ollifi Posted June 2, 2011 Share Posted June 2, 2011 Why you cannot stop using urls with ending slash / ? Quote Link to comment https://forums.phpfreaks.com/topic/237258-using-titles-rewrite/#findComment-1224161 Share on other sites More sharing options...
eevan79 Posted June 2, 2011 Author Share Posted June 2, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/237258-using-titles-rewrite/#findComment-1224163 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.