Is it possible in any way to remove index.php in url without using .htaccess
if yes then how.
and if not then how to make htaccess file in xampp server.
how to apply this in live server.
i tried to make through class but i think it is not possible but i want to be sure so please help me on this ...
what i find is something like
$route['(:any)'] = 'index.php/$1';
in htccess every where so i believe it is not possible because it is something doing nothing with php or any language it is server thing and only chance or way we have is htaccess
Related
At the moment I am trying to move a website to a new web server. The site uses CodeIgniter and on the old server, every route worked. On the new server none of them are working, even though I copied the entire website from the old server. This means there are no differences in .htaccess files, since the two servers contain the exact same website. Not even the default routes are working, just the home page (index.php). I included the code in .htaccess to remove 'index.php' from routed URLs, but that also does not work.
If I try to visit '1.1.1.1/~user/employees' it will give me a 404 error, which means that the CodeIgniter route is not working. The controller file is located at /application/controllers/employees.php, so I am not sure what causes the problem.
I am aware of the similar posts on the site here, but none of them could solve my problem. Configuration of the config/config.php is (partly) as follows:
$config['base_url'] = '1.1.1.1/~user';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
I have tried to change the base_url, but it still does not work if it's empty. Changing uri_protocol to REQUEST_URI or PATH_INFO also does not work. Also, if I try 1.1.1.1/~user/index.php/employees (so put 'index.php/' in between) I still cannot reach the page. I checked some Apache settings as well, AllowOverride is set to ALL and the mod_rewrite module is installed and enabled. Is there perhaps something else concerning differences in both server's configurations that I could have missed?
EDIT:
I think I am a bit closer to finding out what the problem is. It is either something with Apache or .htaccess (but I already tried many things) or it has to do with the fact that the server URL is 1.1.1.1/~user rather than 2.2.2.2 as it was on the old server. Maybe I should change the baseurl or location of my .htaccess? This looks similar to my problem, but moving the .htaccess did not fix the problem: Url routing errors in php in codeigniter. I might try re-installing Apache.
I think that you firstly should find out what happened.
All requests to CI go through index.php, so you just echo something and exit in index.php file at the first line.
If the page display what you echoed that means there is something wrong in CI, otherwise that's not because of CI. And you can focus on what cause the problem.
Sorry about my English.
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.
I have CGI-handled PHP server and basic authentication is not working since PHP_AUTH_USER returns empty string.
I've searched a lot and there was only one solution to this: using .htaccess rewriterule.
The problem is I can't edit .htaccess for some reasons. I want to know if there's a way to do the authentication without changing the htaccess file?
I am trying to do a URL Rewrite, but no matter how I try, it seems like the htaccess file do not functioning at all, and it is only returning the directory listing.
Can anyone tell me what else do I need to look at to make it work?
Regards
PlayKid
Make sure you have AllowOveride All set in your vhost conf file.
Please how can I rewrite
Could anybody please rewrite this url?
http://localhost/display_news_cat.php?news_cat_id=14&p=2
to
http://localhost/display_news_cat/14/2
Thank you
Create an .htaccess file in the site directory and add the following lines
RewriteEngine on
RewriteRule ^display_news_cat/([\d]+)/([\d]+)$ display_news_cat.php?news_cat=$1&p=$2
Afaik, this is normally accomplished with Apache .htaccess file rewrite rules.
Is you case this would look something like:
RewriteEngine on
RewriteRule ^display_news_cat/([0-9]+)/([0-9]+)$ display_news_cat.php?news_cat_id=$1&p=$2
If this doesn't work, try checking your access logs to see what's happening.
there are different ways to archive this, and it takes only 1 minute to find this out yourself using google. you could:
use an .htacces file with rewrite-rules to let the apache do the rewriting
map everything on localhost/ to an index.php, read and parse the request-string "by hand" hand show the correct site
Also you can hold it in one script use GET to retrieve the values you wish and re-create the URL with that values. I don't know if it will help you..
Anyway a .httacess file will be much more useful for you.