Jump to content

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]
Edited by jazzman1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.