charl9cfc Posted May 27, 2013 Share Posted May 27, 2013 Hi AllAm trying to change the following url:http://mywebsite.com/gallery/cuisine/?nggpage=2linkid446 to read:http://mywebsite.com/gallery/cuisine/?nggpage=2?photoid=446 Have tried the following rules, but it does not want to change the url: RewriteCond %{REQUEST_URI} ^/gallery/cuisine/?nggpage=2linkid$1[a-z]+([0-9]+)$ RewriteRule ^(.*)$ /gallery/cuisine/\?nggpage=$2?photoid=%1 [R=301,NE,L] Regards,Charl Link to comment https://forums.phpfreaks.com/topic/278424-mod_rewrite-change-url/ Share on other sites More sharing options...
jazzman1 Posted May 27, 2013 Share Posted May 27, 2013 Assuming, that a /gallery is a sub-directory of your project. Inside /project/gallery/cuisine directories you have for example a index.php containing next links: /project/gallery/cuisine/index.php <a href="./index.php?nggpage=1linkid446">Link 1</a><br /> <a href="./index.php?nggpage=2linkid447">Link 2</a><br /> <a href="./index.php?nggpage=3linkid448">Link 3</a><br /> Inside the root directory of your project folder named above as "project" create your .htaccess file: RewriteEngine on RewriteCond %{REQUEST_URI} ^/project/gallery/cuisine/index\.php$ RewriteCond %{QUERY_STRING} ^nggpage=([0-9]+)[a-z]+([0-9]+)$ RewriteRule ^(.*)$ /project/gallery/cuisine/?ngpage=%1\?photoid=%2 [R=302,L] OR.... RewriteRule ^(.*)$ /project/gallery/cuisine?ngpage=%1\%3Fphotoid=%2 [R=302,NE,L] Link to comment https://forums.phpfreaks.com/topic/278424-mod_rewrite-change-url/#findComment-1432525 Share on other sites More sharing options...
jazzman1 Posted May 27, 2013 Share Posted May 27, 2013 EDIT: A little mistake I made, before a "?" symbol it should be a "\" symbol instead "/" to be escaped, sorry for that. No, no it's just fine Link to comment https://forums.phpfreaks.com/topic/278424-mod_rewrite-change-url/#findComment-1432529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.