Shortcut url using classic redirection - php

I am doing a redirection to a path. The php redirection using headers start at www.example.com and redirects to www.example.com/themes/mypage/login.php. I know htaccess can help create a shortcut url but that url has to be typed in. I have recently achieved this using htaccess but my css and scripts ain't working. How can i solve this?

Related

Redirect if someone add / to the url

i just wanted to know that how to remove more than one / from url from htaccess forex:-
This is the original url
http://example.com/folder/page.php
What if someone add another slash to folder like this
http://example.com/folder//page.php
It still showing page content but without any css and script. And how to prevent from adding /\ and redirect to the original url.
I am seeing this in most of the websites they redirect but my website is not redirecting.
I don't know it's a server issue or programmers issue. I contacted my hosting manager they are saying it's a programmers issue.
Can you please help me out with this
How to prevent from this and redirect using htaccess

PHP site to angularjs site redirect with hashbang

I am redirecting from my old domain in php to new domain built in angularjs(with hashbang #!). i have set up the redirect in the .htaccess file and the redirect works fine. But php replaces the has with %23. So the path is not recognized by the angularjs views config. How can i overcome this?
Take a look at your .htaccess file to see if it has a No Escape flag.
http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_ne
It looks like the rewrite rule is escaping the hash.

How to redirect url with %2F using .htaccess in php

I am trying to redirect URL http://www.example.com/author/Hermann+%2F+Kohn
TO http://www.example.com/author/Hermann+Kohn using .htaccess file in php but not able to achieve target result.
So can anyone please guide how to achieve it

URL Rewriting in PHP using Wordpress

I have to continue on a project that has been developed by someone else. It is a web portal developed using PHP and Wordpress. I am using the code uploaded on localhost.
I had a fundamental question regarding URL rewriting in PHP. I have a link on the front page which says
a href="<?php bloginfo('url'); ?>/search?refer=registered&link=registered
But when I click on it, it gives a 404 error.
How do I set the URL mapping "search" -> "wp-content/themes/mytheme/page-search.php"?
[UPDATE: I found the solution myself. It had to be done through Wordpress by creating templates and setting the URL to point to the corresponding template file.]
wordpress build in url rewriting is in backend after you login /wp-admin/
go settings>permalinks where you can choose the re-write rules and click save button.
wordpress will then auto write a .htaccess file (this file is for url rewriting )
with the rules created in it.
if you find rewriting isn't working (eg, returns a 404 page) then u need to make sure your server has opened the url-rewrite mod for urlrewriting.

How to redirect in a php project running in localhost?

Suppose i have a link generated in php:
http://localhost/Example/www.someDomain.com
now i would like to go to www.someDomain.com , can you please help me with the proper method (probably via .htaccess) to redirect to desired location.
I tried using php header function and js window.location.replace(" ") but it dint' helped.
***Problem with window.location.replace("www.someDomain.com") is that instead of redirectng to www.someDomain.com , the page redirects to http://localhost/www.someDomain.com
I am using Wamp server if it helps.
Help please and also suggest some nice resource to study about .htaccess
Thanks
If I understood.
you need to put te entire URL with "http://".
Javascript:
<script>
window.location.href=("URL");
</script>
OR in php:
<?php
header("location:$redirect");
?>
You can use window.location or PHP header() function, but for redirect to another site must prefix with http://.
header("Location: http://www.example.com");
You can also do the same through Apache .htaccess with a Redirect rule.
htaccess is NOT going to help you at all. If all your links look like: http://localhost/... then in order for htaccess to redirect, everyone who goes to your site would have to be running a webserver on their local machine and have an htaccess file that redirects to your site.
You need to fix your php scripts so they generate the correct hostname. Using javascript to redirect isn't even a viable solution, because in order for the location to be "localhost", they're already loading no content because they're trying to connect to their own machine.
If for whatever crazy reason you can't fix your scripts, you may have to look into using mod_proxy_html on your site and dynamically change all your "localhost" to your domain.

Categories