Mobile app version of vmapp.org
Login or Join
Kaufman445

: SEO Joomla URL to WordPress URL's I am trying to migrate from Joomla 1.5 SEF URL's to WordPress SEF URL's. The old links use this formatting: /site/sectionname/categoryname/id-titlename.html I want

@Kaufman445

Posted in: #Htaccess #Joomla #Migration #ModRewrite #Wordpress

I am trying to migrate from Joomla 1.5 SEF URL's to WordPress SEF URL's.


The old links use this formatting: /site/sectionname/categoryname/id-titlename.html
I want to migrate it to /wp/index.php?p=id


I have modified my .htaccess file but it doesn't seem to work.

RewriteEngine on
RewriteRule ^/(.*)/(.*)/[0-9]+-(.*)$ /index.php?p= [L]


Does anyone have an idea how I can resolve this issue.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Kaufman445

3 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

Your regular expression has the following problems:


It only has .* for the "site" and "sectionname", but is missing one for the "categoryname". Based on your example, there should be a third directory level in your regex.
You have parenthesis around items which you don't need to reference, but no parenthesis around the ID, which you will need to reference. You should remove all the parenthesis that are currently in there regex, and put some around the id: ([0-9]+)
It would be better to use a character class rather than .*. The dot is greedy and will match everything including the following slash. A regular expression written with multiple .*s in it will require the regular expression engine to do lots of extra "back tracking" work. The regular expression will not perform as well as it should.
The . in .html matches any character, not just a literal period. You should escape the . in this place: .html
If this rewrite rule is meant for .htaccess, the regular expression should not start with a slash, the starting slash is assumed in the context of .htaccess. Rewrite rules should only start with / when they go in httpd.conf
If you want your rewrite rule to redirect rather than show the contents at the existing URL, you should change [L] to [L,R=301]


Here is a regular expression that may work better for you. This assumes that only letters, numbers, underscores and dashes can appear in categories, titles, and such.

RewriteEngine on
RewriteRule ^[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+/([0-9]+)-[a-zA-Z0-9_-]+.html /index.php?p= [L]


You could also try putting this regular expression in the redirection plugin mentioned in Timothy's answer.

10% popularity Vote Up Vote Down


 

@Heady270

I think you could resolve this specific issue by modifying your Rewrite rule a little bit to capture the post id and pass it on. Currently, you are passing in the post title, when you should pass the id.

RewriteEngine on
RewriteRule ~/.*/.*/([0-9]+)-.*$ /index.php?p= [L]

10% popularity Vote Up Vote Down


 

@Holmes151

If you are using Wordpress now, and simply trying to redirect old Joomla urls to your new urls I suggest using a plugin to make your life easier.

I recommend this plugin a lot:
wordpress.org/extend/plugins/redirection/
Also keep in mind that you should use fancy permalinks within Wordpress instead of the standard ID numbers. You can find this setting in the Settings options in wp-admin!

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme