oxxxis Posted August 27, 2010 Share Posted August 27, 2010 Hi, I am trying to create bautyful links using mod_rewrite, i'm not experienced in php. My goal is to rewrite www.page.com/?example to www.page.com/example/ and www.page.com/?example=1 to www.page.com/example/1/ Can someone please help me with this? I tried: RewriteRule ^([^.])$ /$1.php and RewriteRule ^([^/=&]+)[/=&]?$ ?$1 [L] But I just can't get it right Link to comment https://forums.phpfreaks.com/topic/211842-help-with-rewriting/ Share on other sites More sharing options...
cags Posted August 27, 2010 Share Posted August 27, 2010 You have the concept flipped on it's head. You don't rewrite www.page.com/?example to www.page.com/example/ you actually rewrite the opposite of that. Therefore you need to make all links on your page appear like the second version, and you need to make the mod_rewrite rules match the second version. So for example your rule might be... RewriteRule ^example/([0-9]+)/? /?example=$1 Your first rule rewrites requests for pages that don't have a file extension and adds .php to them and your second uses some code that irrelevant, but is close to being another method that will work for you. Link to comment https://forums.phpfreaks.com/topic/211842-help-with-rewriting/#findComment-1104313 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.