I need an htaccess file that makes it so when you go to my url: http://www.domain.com/content-title-here-12345 it takes you to http://www.domain.com/viewPage.php?id=12345 and so on and so forth for any URL e.g. http://www.domain.com/content-22334 ===> http://www.domain.com/viewPage.php?id=22334 http://www.domain.com/content-page-here-etc-33221 ===> http://www.domain.com/viewPage.php?id=33221 And I can't quite figure it out, any help?
I think you mean to load data of view.php?show=1234 on /content-1234/ You can use this code for that: Options -Indexes +FollowSymLinks RewriteEngine on RewriteRule /content-(.*)/$ view.php?show=$1 [R=301,L] Code (markup):
I'm assuming the OP doesn't want to name everything "/content-" but that ANY link with an ID on the end should redirect (why, I've no idea, it's a stupid system, but hey) You would need a regex for checking for a number (however, that might break if there's more than one number in the link) Besides, why don't you rather redo the links? Instead of tacking on the ID on the end like that, either look up the ID based on the actual url, or if that's not feasible (say, multiple same-name urls with different IDs), do either a /ID-goes-here/content-title-goes-here or /content-title-goes-here/ID-goes-here?
I wouldn't recommend directing /title-id, maybe something like post/title-id so you don't interfere with any other URLs. RewriteEngine On RewriteRule ^post/(.*?)-([0-9]+)/?$ viewPage.php?id=$2 Code (markup): Simply remove post/ if you want it to work like you originally intended.