1

Is there a way to add a cname or txt or whatever record to redirect a page on the same domain to another page. I don't want to redirect the whole domain to another one. Not sure how to do this.

For example I need to redirect:

https://example.net/index.php/page

to

https://example.net/page

1
  • 1
    The DNS does not deal with HTTP redirections. The DNS in your case maps names to IP addresses, and webservers at those IP addresses have to deal with doing the proper HTTP redirection based on your needs. The example you give is trivial to achieve and there are many many many questions here and on Stack Overflow about redirections. Aug 15, 2019 at 17:00

3 Answers 3

2

You can't use DNS to implement redirects. A CNAME DNS record is not a redirect. A CNAME simply says that the domain name resolves to the same IP address as another domain name. It doesn't make that domain name redirect. DNS also doesn't know anything about URL paths. Using DNS just isn't the correct tool for the job.

If you want the domain to redirect, you need to run a web server and have the web server issue redirects. It doesn't matter if the DNS points to that web server with A or CNAME records.

In your case where you have a single domain name and you want to issue a redirect from one page to another, you need to to configure your web server to redirect that page. The instructions for doing so depend on which web server you use. Most commonly it would be implement in a .htaccess file for the Apache web server:

Redirect permanent /index.php/page /page

If you have rewrite rules in place to use index.php as a front controller, that rule may conflict and not work for you. The other common redirect method would be to implement it within the PHP itself. If you want to use that, look at this post on StackOverflow: How do I make a redirect in PHP?

0

Rather than editing a cNAME record which won't work, why not use an HTTP refresh code?

<meta http-equiv="Refresh" content="5;url=https://example.net/page">

This way, the page with the code above would redirect to the URL https://example.net/page after 5 seconds. you can make it redirect instantly by changing 5 to 0

1
  • Thank you for taking the time to answer! In general, HTTP-level (301/302) redirects should always be preferred over meta refresh redirects, whenever possible. It would also be great if this comment were to address the difference between DNS records vs redirects, which could be beneficial to the OP. Aug 15, 2019 at 22:06
0

If you are using Cloudflare as your DNS manager I hope their "Page Rules" will help you. In free plan you can get up to 3 page rules and yes you may also use wildcards.

Cloudflare documentation on page rules : https://support.cloudflare.com/hc/en-us/articles/218411427-Understanding-and-Configuring-Cloudflare-Page-Rules-Page-Rules-Tutorial-

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.