Reputation: 19037
I have to do some maintenance of one angular project which has a PHP backend. I have never worked on PHP so I am trying to locate how URL's are configured in PHP project. I just want to redirect /careers and /apply to index page currently it gives me page not found.
Simply I want to change the url from /apply to #/apply and server the index.php file
Upvotes: 1
Views: 137
Reputation: 166
You are using angularjs so routing is also best option for you.Please check this link it might be helpful.
http://scotch.io/tutorials/javascript/single-page-apps-with-angularjs-routing-and-templating
and if you want in php only then
header("Location: index.php");
there are different ways also but it is easy.
Upvotes: 2
Reputation: 2137
This is an easy way to redirect:
header("Location: index");
die();
That line of code sends a HTTP header to the client to tell it to redirect. To do this, just put this code at the top of your PHP file:
<?php
header("Location: index.php");
die();
?>
so I am trying to locate how URL's are configured in PHP project
Simply put, they work very similarly to how HTML files are setup. When you load www.example.com/index.php
, there's a PHP file called index.php
in the root of where the webpage is stored.
You can also do redirects with .htaccess
files/other config files so it'll be www.example.com/index
, but that's not inside PHP.
Upvotes: 1
Reputation: 647
I think this is easier to achieve with .htaccess:
RedirectMatch 301 ^/apply/$ http://domain.tld/
RedirectMatch 301 ^/careers/$ http://domain.tld/
Upvotes: 1
Reputation: 4723
This is because you need to add .php to the url (/careers.php), if you want to have clean url's like /careers
instead of /careers.php
you need to use a .htaccess
file with the following code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
or
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Upvotes: 0