If my root website www folder is /
and the subdomain folder is /subdomain
I can either get to the the address using one of the following
http://subdomain.website.com/
http://www.website.com/subdomain
Now if I access the site using the http://subdomain.website.com, The codeigniter treats the base_url() as http://subdomain.website.com/subdomain is there away of stripping the subdomin from the end if the subdomain segment has the same name?
I could strip it on a case by case basis, but I'm hoping there is a way to do this using one of the system configuration files.
Whatever you are asking, has something to do with setting up dynamic base url in codeigniter. They have been answered here and also here.
Hope you find it helpfull.
Related
I came across problem in laravel, cant find a solution, maybe you could help me out.
I have many folders with HTML documents that are linked (same folder as HTML) with css, some of css are inside assets, includes, root folder.
I can access these html files by going https://website.com/live/1/index.html but the problem is that laravel sees css and other files in website root folder https://website.com/assets/app.css instead of https://website.com/live/1/assets/app.css
I think I could find a solution in htaccess by typing RedirectMatch 301 ^/(assets/.+)$ /live/1/$1 but then it means, that I have to create and edit htaccess everytime for a new folder.
Maybe someone has any solution to this problem ?
You can change your default asset URL with your .env file and add this
ASSET_URL=https://website.com/live/1
it would change your asset() method behavior
I need to show to my client the progress of a project that is already in the shared host.
In development, acessing just /localhost/ worked to me, but now that I've sent the files to the host (cPanel), it's breaking in some cases because I need to use the /~cpanelname in the IP. Is there a way to add this /~cpanelname to every URL? After the deployment and insertion of a domain, it will need to be removed also.
The problem basically is:
When I have an image, the src is:
[IP]/img/img.jpg
When it needs to be [IP]/~cpanelname/img/img.jpg
A link href that is /about needs to be /~cpanelname/about
Can you guys help me?
Thanks!
You should be using the asset(), route(), url() etc. helpers to construct all of your links and file references.
If you've done that correctly, you can then change the base URL for all URLs just by changing the config/app.php file's url parameter (typically by changing APP_URL in .env).
UPDATE
If I browse url like
localhost/myapp/index.php/about_us/index
it works. What is this index.php in url? Do I need to mention it in some config file so that it gets appended and forms correct url in menu/links on site?
Original Question
I have no knowledge of PHP but I got a project which in php (codeigniter) to convert in Ruby on Rails.
I could set up db and application well, when I browse application with base url(without mentioning controller & action) it loads page properly. But as soon as I mention url like
localhost/myapp/home/index
it shows message
The requested URL was not found on this server.
If I change default controller to anything in routes.php that page with index method works fine but not with explicit mentioning controller and action.
I am not sure what is the issue, I don't know how routing works in php :(
Any help will be appreciated.
In CodeIgniter, all requests are directed through the index.php file, which acts like a front controller.
index.php must be present in the URL unless you have created a solution to eliminate it. When using Apache, that is typically done with an .htaccess file. There are hundreds of articles and questions regarding this technique -- certainly you can find something to help you.
In regards to URLs and a config option for defining index.php, CodeIgniter URL helper functions such as site_url() utilize the config setting $config['index_page'] found in application/config/config.php. If you remove index.php from your URLs using an .htaccess solution, you can make this setting blank:
$config['index_page'] = '';
This setting is useful for when you want to rename index.php to something else, as well (not very common).
It seems that you had not configured your web server properly. See this question for details for Apache: routing problem in codeigniter
And here are rules for nginx: http://wiki.nginx.org/Codeigniter
Using a routing rule in a Symfony project the function link_to (or url_for) generates an url like mydomain.com/myproject/web/friendly-name.html or mydomain.com/web/friendly-name.html
There is a smart way, alternative to write own helper, to generate urls without /myproject/web or /web keeping the choosen directory structure.
Updating
Finally I found the solution in the answer to this question: symfony on virtual host document root problem
just point your webserver Document Root to /web Directory.
This is the right way of integrating symfony1.4.
Cheers malte
I m doing web application in cakephp1.3. I want my Url
http://mydomine.com/cakephp/users/login to be display as http://mydomine.com/users/login.
Where users is controller name and login is action. I dont want to display cakephp on my url. Please help me to fix this bug.
Thanks in advance
Pushpa
You can direct your domain to the cakephp directory... No need to work with rewrite.
either move all the files from the cakephp folder to the / folder,
or use apache rewrite rules to remove cakephp from the request
Put all of the content of your app dir to your web folder and then u will be able to access home page of your project directly. Don't forget to copy .htaccess.