I'm new in codeigniter. i have a project running perfectly in my localhost. when i deployed, my links seem to be broken. e.g. mysite.com displays the homepage without any error. now, i have a link let's say an about us link e.g. mysite.com/main/about where main is my controller and about is my function. the problem is the about us link is broken e.g. "Oops! This link appears to be broken." do you have any idea where did i go wrong? thank you for any positive response.
It looks like you have configured your application to remove /index.php/ from your URLs, but I suspect you have not included the .htaccess file to provide mod_rewrite support.
If you want to exclude /index.php/ from your URLs, make sure you follow everything in this tutorial.
Or, to get your site working ASAP, restore the default value of index_page in system/application/config/config.php to:
$config['index_page'] = "index.php";
I'd check 2 things first.
Your base site url is properly configured to either the correct url or $config['base_url'] = 'http://'.$_SERVER['HTTP_HOST'];
Your .htaccess file is properly configured and you have the mod_rewrite apache module installed.
You have to make sure the links are either relative to the path or use the base_url() function provided by the URL helper. See URL Helper.
Can you try to use this code below, hopefully it will works :)
RewriteEngine On
RewriteCond $1 !^(index.php)
RewriteRule ^(.+)$ index.php?$1 [L]
Related
I've got a CMS which I created by myself and I have an external link, which shows the web created by the user.
The link is: http://localhost/CMS/www/users_template/{user_name}
Is there any possibility to change the link and make it:
http://localhost/CMS/{user_name}
but it should still show the web page without any errors?
I think I should edit my .htaccess file, but no idea how to do it. I have never edited the .htaccess file before.
This is a duplicate.
Please view .htaccess: removing part of url path and stay at base
RewriteEngine On
RewriteBase /CMS/
RewriteRule ^www/users_template/(.*)$ $1 [L,R=301,QSA]
I am trying to redirect www.example.com to /example/ on my webserver, but it appears to only be redirecting the index.php page. An additional issue is the main file displays as http://tunedu.com/tunedu/ when I would like it to display as tunedu.com
Live example:
This page works: http://tunedu.com/tunedu/
This page doesn't work: http://tunedu.com/school.php?id=75
Any regex changes I do try end up just breaking everything. The .htacess code is this:
RewriteEngine on
RewriteRule ^$ /tunedu/ [L]
Thanks.
The proper way to do such a thing is by setting VirtualHosts on your webserver (either Apache, nginx or another...). Using htaccess for this seems quite painful.
Assuming you're using Apache, here's a useful link: http://httpd.apache.org/docs/current/vhosts/examples.html
I'm not sure why you are not using VirtualHost to set that up.
But in case you want to go the mod_rewrite way here is an useful link:
http://httpd.apache.org/docs/2.2/rewrite/vhosts.html
I hope that helps.
I have been using code igniter as a subdirectory of a site and have several instances of if on one server. Each instance is considered a separate application, but all under the same domain name. I am looking to enable a slightly different URL structure though and have turned to mod_rewrite to help me out.
The page is reachable at http://localhost/test but I want to rewrite that URL to appear as http://localhost/en-US/test.
The problem is I keep getting a code igniter (CI) 404. I can confirm the mod_rewrite is reaching the CI index.php, but CI is failing to deliver the correct page. Here's and example setup:
1) Download a new instance of CI and place it in a subdirectory in the site root. Name the CI folder "test". It should be reachable now on a local server at http://localhost/test and you should see the default welcome view.
2) Create a .htaccess file in the server's root web directory. DO NOT place it in the CI "test" directory. Add the following lines to it.
RewriteEngine On
RewriteBase /
RewriteRule ^en-US/test/?$ test/index.php [NC,L]
From my understanding of mod_rewrite, this should allow the URL http://localhost/en-US/test to render what is located at http://localhost/test. It doesn't though. I just get the CI version of a 404. I need help figuring out how to resolve this.
Hmm your question made me install CodeIgnoter and read its routing :)
Anyway have your DocumentRoot/.htaccess like this:
RewriteEngine On
RewriteBase /
RewriteRule ^en-US/(test)/(.*)$ $1/$2 [NC,L]
Then replace this line in your /test/application/config/config.php`:
$config['uri_protocol'] = 'PATH_INFO';
It is by default set to:
$config['uri_protocol'] = 'AUTO';
After this you can open this URL: http://domain.comen-US/test/ to load CI home page in /test/ dir.
You should check out routing. Place this statement in your config/routes.php file AFTER the reserved routs.
$route['test'] = "en-US/test";
You can forget about htaccess when you have Codeigniter (most of the times).
I'm in a situation where my web page have the following types of URL's
http://mysite.com/?type=home
http://mysite.com/?type=aboutus
http://mysite.com/?type=contactus
For the end users I need it to display like the following:
http://mysite.com/home
http://mysite.com/aboutus
http://mysite.com/contactus
This means, the user is not aware that the URL have a request parameter "type" in it.
I'm not sure it is possible or not.
Please help me to get to a solution.
EDIT: I searched lots of websites to learn URL rewrite by using .htaccess, But didnt able to make them working in my server.
Place this in you .htaccess file
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-+/]+)$ ?type=$1
RewriteRule ^([a-zA-Z0-9-+/]+)/$ ?type=$1
Yes it is absolutly possible.
Your have to be sure your hostprovider has enable URL rewriting (I don't really remenber but I'm sur you can find help on Internet to verify that).
You have to create an ".htaccess" file at the root of your site.
Put this content in it :
tell the server to follow symbolic links :
Options +FollowSymlinks
activate the rewrite module :
RewriteEngine on
Rule for rewrite url
RewriteRule ^([a-z]+)$ /index.php?type=$1 [L]
Note this is just a qucik exemple you may want to look "url rewriting tutorial" on Google.
I'm using following code:
$config['base_url'] = "http://www.aaa.com/";
Also Im using Flash navigation:
on(release) {
getURL("http://www.aaa.com/xxx/index");
}
The Problem is When I give url as http://aaa.com in address bar Flash navigation link is not working. If i give link from http://www.aaa.com its work perfectly.
Can anyone solve my issue?
Or else, is it possible to use like this:
$config['base_url'] = "http://www.aaa.com/";
$config['base_url'] = "http://aaa.com/";
This question is quite vague. But to redirect to www using .htaccess try:
RewriteCond %{HTTP_HOST} !^www|localhost
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
Is the flash object trying to read a page / data from the server?
In this case, Cross-domain policy for flash prevents form accessing data which resides on other domains. (Sub domains, such ass www.aaa.com and aaa.com are treated as different domains.)
You would need to add a crosdomain.xml policy file http://kb2.adobe.com/cps/142/tn_14213.html
If Petah's answer doesn't help you, then it could very well be a setting with your web server. I use shared hosting and I know whenever I configure a new domain I have an option like this:
If you own your own web server, check the httpd.conf file. Otherwise, if it's on shared hosting, see if there's a setting for making it required/non-required.