[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

redirecting url (PHP server)

Posted on 2010-03-30
7
Medium Priority
?
272 Views
Last Modified: 2012-05-09
I have a link like this:

http://www.myurl.com/function/

What I want to do here is that whenever someone visits that link they will be redirected to:

http://www.myurl.com/index.php/function/

How can I do this?

Any url from function/ onwards should also be redirected:

from -> to

http://www.myurl.com/function/do.php -> http://www.myurl.com/index.php/function/do.php

http://www.myurl.com/function/index.html - > http://www.myurl.com/index.php/function/index.html
0
Comment
Question by:Bandai2
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 6

Expert Comment

by:mmarx82
ID: 29091534
Use this:

<meta http-equiv="REFRESH" content="1"; url=http://www.the-domain-you-want-to-redirect-to.com">

Put the above between your Head tags. Content is the number of seconds before the redirect takes place, It's not a good idea to use 0 as some browsers do not support it.

0
 
LVL 6

Assisted Solution

by:V4nP3rs13
V4nP3rs13 earned 400 total points
ID: 29091659
header("location: index.php/function/index.html");

or yot can use mod rewrite in htaccess
0
 

Author Comment

by:Bandai2
ID: 29092319
I read about mod rewrite i think its the solution i'm looking for... but it seems very complicated.. can you tell me how I can do this by using mod rewrite?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 12

Accepted Solution

by:
Avinash Zala earned 1600 total points
ID: 29092453
use below htaccess rule:


RewriteRule ^function/([a-zA-Z]+).([a-zA-Z]+)$ index.php/function/$1.$2 [R=301,L]
RewriteRule ^function/([a-zA-Z]+).([a-zA-Z]+)/$ index.php/function/$1.$2 [R=301,L]

This will redirect permanent.

Hope this helps.
Addy
0
 

Author Comment

by:Bandai2
ID: 29093066
I tried it like this and it works:

Redirect /function http://myurl.com/index.php/function

what's the difference between this and the code given above? This is much simpler? but is the code above much better?
0
 
LVL 12

Expert Comment

by:Avinash Zala
ID: 29093692
This is the url rewrite method with Apache rewrite module.

It is the standard method for redirecting the urls.


Hope this helps.
Addy
0
 
LVL 6

Expert Comment

by:V4nP3rs13
ID: 29114307
Using mod rewrite is better than using redirect, because some of your website visitors may access your site via their bookmarks, so, he can access on old and new links. You have both.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
Magento is the best technology for eCommerce start-ups as it offers the technical expertise and visual appeal to create a store that pulls sales and earns high ROI (Return on investment).
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question