Jump to content

mod_rewrite change url


charl9cfc

Recommended Posts

Hi All

Am 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

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.