1

Topic: redirect url dynamically htaccess

I need to redirect specific URLs to their new equivalent.
i have a single dynamic page(pages.php) and i fetch data from database.(like domain_name.com/pages.php?id=4)
and i want to redirect to
domain_name.com/pages/name
or
domain_name.com/name

on same page with different names(for example if pages.php id=4(example-  domain_name.com/pages.php?id=4) and id 4 have name welcome then url goes
domain_name.com/welcome
or
domain_name.com/pages/welcome
or
if pages.php have id=5(domain_name.com/pages.php?id=5) and id 5 have name faqs then url goes domain_name.com/faqs or
domain_name.com/pages/faqs 

and my query string is

<ul>
                   <?php foreach($moreinfo as $moreinfoarr){?>
                <li><a  href="pages.php?id=<?php echo $moreinfoarr['pageId'];?>"><?php echo $moreinfoarr['menutitle'];?></a></li>
                <?php }?>
                                </ul>
will you plz help me

Last edited by harjinder (2014-01-15 05:25)

Thumbs up 0

2

Re: redirect url dynamically htaccess

anyone here to help findout the solution of redirect url dynamically.......????

Thumbs up 0

3

Re: redirect url dynamically htaccess

1. Is this something custom and why are you not using Pages for your content?
2. Check repository for Redirector plugin.
3. You have:

<?php foreach($moreinfo as $moreinfoarr){?>

What does $moreinfo do? Paste the whole code here.

Tutorials at Project 79 | Wolf CMS Docs

4

Re: redirect url dynamically htaccess

it was function to fetch data from database by quary

like

$sql="select * from tablename where status='1'";
$result=mysql_query($sql);
while($moreinfo=mysql_fetch_assoc($result))
{

........

}

and my htaccess code is:

RewriteCond %{HTTP_HOST} ^domain_name\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain_name.com/$1 [R=301]
RewriteRule ^pages/([^/]*)/$ /pages.php?id=$1 [L]

i was also try with:

RewriteEngine On
RewriteCond %{QUERY_STRING}   ^id=([0-9]+)$
RewriteRule ^pages\.php$   http://www.domain_name.com/pages/%1? [R=301,L]
or

RewriteEngine On
  Redirectmatch 301 /pages.php?id=11 http://www.domain_name.com/about-us [NC]
  RewriteRule  /pages.php?id=$1 ^/(.*)$ [R=301,NC,L]

but that was not work.

Last edited by harjinder (2014-01-16 06:39)

Thumbs up 0

5

Re: redirect url dynamically htaccess

We had similar problem a year ago or so and here is the solution. Though this is in a form of a very simple plugin + model.
This is the easiest way to map your custom url's/data/whatever by using Dispatcher and display them via view.
I've done this few years ago in combination with pages and still runs smoothly smile (and it's way better than .htaccess)

Tutorials at Project 79 | Wolf CMS Docs

6

Re: redirect url dynamically htaccess

thanks for the reply but my website is totally in core php. then how can i implement this plugin..??

Thumbs up 0

7

Re: redirect url dynamically htaccess

What do you mean by "my website is totally in core php"?

How do you input your content? Via Pages or something else?

Tutorials at Project 79 | Wolf CMS Docs

8

Re: redirect url dynamically htaccess

the content was input by admin panel and every thing was controlled by admin panel dynamically like slider pics, menu items, products etc..

but my my website is not in any CMS like (wordpress, joomla) it was in core php.

Last edited by harjinder (2014-01-17 05:22)

Thumbs up 0

9

Re: redirect url dynamically htaccess

So you are now switching to Wolf and want to import your stuff in?
Or you just want to access your second db and pull the content + make clean url's?

Can you export your current stuff in .csv?

Tutorials at Project 79 | Wolf CMS Docs