This is one of those problems that make me question my sanity. I'm using php, codeigniter framework, removing index.php from URL with mod rewrite in htaccess.
I'm at this address
http://localhost/health/users/bob/progress/
I click a link that takes me to
http://localhost/health/users/bob/progress/01-04-15
Then I click on a link that takes me back to
http://localhost/health/users/bob/progress/
Now here's the strange thing. I click on the same link that earlier took me to
http://localhost/health/users/bob/progress/01-04-15
But instead, now it's taking me to
http://localhost/health/users/bob/progress/progress/01-04-15
I've gone through the steps a dozen times now. This is definitely the behavior it's giving me. It even happens when I do a full refresh. I actually have to visit a different address, then return to get the link at
http://localhost/health/users/bob/progress/
to work properly again. I'm guessing it's either related to the mod rewrite, or some other rewrite behavior in the codeigniter framework.
I'm pretty sure you are using a relative path for the link that goes something like:
link here
I would suggest that you use CI's base_url instead so that the link becomes absolute:
link here
the base_url is set on your configuration file. Please let us know how it goes!
My guess is that your link looks something like the following, and because of that it get's appended to the current url
href="progress/01-04-15"
Try making your link using absolute path, preferably appending it with base_url or current_url from codeigniter + progress/date.
href="http://localhost/health/users/bob/progress/01-04-15"
That way you will get to the correct link every time, instead of appending it to current url.
Related
I'm working on an application using php framework Laravel.
I've encountered a problem since I need to open a modification form with two parameters. I pass them in my url like so:
<tr class="beBlack" onclick="document.location = '/showGriefs/{{$data->No_Grief}}/{{$data->No_Employe}}'">
(I know that it is sketchy to create a link within a table but I need the url to change according to which row is clicked/selected)
and I receive them in the following route:
Route::any('/showGriefs/{No_Grief}/{No_Employe}', 'GriefController#showGrief')->name('showGriefs');
My problem is that I don't want my url to change, because, with these url changes, my application can't find the files (CSS, JS and Plugins). And since laravel is using the public directory to store all those files, it's destroying my page. The only errors I get are some missing files error.
I've searched the internet a lot but didn't found anything, I hope you'll all be able to help me. Thanks.
I know 2 solutions to fix your problem. No need to change route URLs. Just fix asset problem.
1. Use / before asset url
If you use / before url, browser will try to look at resource on the root dir.
For example: if you need http://example.com/assets/img.png then use /assets/img.png. Changing URLs will not affect the asset URLs that starts with / character.
2. Use url helpers for asset URLs
asset('assets/img.png') will change asset url from assets/img.png to http://example.com/assets/img.png
With help on my last question about removing file extensions from the address bar if the page name and file extension were keyed in directly even after using htaccess to remove them, HERE I'm now wanting to remove index from the url. Specifically, if I type in my webpage's URL into a browser like so: http://webpage.com that exact address is what I see in the browser when the page is served up. However, if I click the Home link on my page, which contains a href="index" naturally, what shows in the address bar is http://website.com/index Certainly, I could change the link in my code to a href="http://website.com" to omit the index portion from showing up in the address bar, but that seems like a hack.
I found an SO article HERE that shows a method for removing index.php but I'm a bit lost as to how, or even if the code in that answer (I get particularly stuck when seeing Rewrite Base /
) can be blended in with the code that was given to me HERE to just remove index after the file extensions have already been removed.
My apologies in advance if this isn't a clear explanation, I'm in new territory here. Many thanks in advance!
Doing proper rewriting requires you to build the correct links that you want to see being used by the web (i.e. users and search engines). Don't use URLs in your own links that point to URLs that you consider to be wrong.
The link to the home page likely should be <a href="/">, if you don't like index.
Trying to fix the problem by making the client do two requests, one for index, then receiving a redirect to /, is the hack here. Fix your links - they are under your control for a reason.
Certainly, I could change the link in my code to a href="http://website.com" to omit the index portion from showing up in the address bar, but that seems like a hack.
No, that's what I would do :-)
I currenlty have a MODx website setup, and I am wondering if it's proper to have my links look like this (And by that I mean my resource alias):
myurl.com/help/configuration/basics.html
Putting the slash in the URL like that... is it a bad practice? My main problem is that this breadcrumb plugin seems to no longer work... :(
I want to have this breadcrumb plugin operational again, if someone would mind helping me.
The Error:
When say using the breadcrumb to link to a page that's myurl.com/code/landing.html and the current page is myurl.com/help/configuration/basics.html, it will then redirect you to a link that doesnt exist, that looks like this:
myurl.com/help/configuration/code/landing.html
As you can see, it is appending the latter portion of the new page's url, but it is not properly removing the URL of the current page, as it only removes the current URL up to the '/' slash....
Does anyone know how to fix this? Possibly a way to make it so that instead of doing it's current "remove" and "append" thing, I can change breadcrumbs.class.php to take the value of the links as if I had clicked the link with the "view" button on the MODx manager? I'm not an expert at php, and it is a must for this to work.
Or are there other alternatives to creating the " / " effect in my links, rather than just putting it in the resource alias? (As I want the site to follow a logical, readable, order)
With all things modx, clear the cache, even if you don't think it could be the issue ~ modx is very aggressive about caching stuff.
Though this kinda sounds like maybe your base href tag may be set to <base href="" />, possibly in your templates it may look like:
<base href="[[++site_url]]"></base>
where site_url is set dynamically [it's not a system setting so don't look for it] in your /core/config/config.inc.php as $modx_base_url ... if that value is blank that could be causing the issue.
Also check your rewrite rules in your .htaccess to see what the rewrite base is. [it should be / ]
then refresh your cache... ;)
I have a problem.
I ma moving a system from one server to another and I came across a peculiar problem. There are some pages placed in a subfolder like these:
xttp://test.domain.com/admin/oders.php
xttp://test.domain.com/admin/users.php
xttp://test.domain.com/admin/whatever.php
Now, when I move around the pages, via some simple menu with links I get most of the times correct hits. But from time to time I end up on say:
xttp://test.domain.com/admin/admin/oders.php - which obviously causes 404
When I go back to previous page and press the link again it again works all right. Also when I hover over the links they always show proper paths regardless of whether I am going to get 404 or not. All links are dynamically generated by the scripts but they work perfectly on old server and as I say to a naked eye it all looks OK, right until I press the link.
Anyone has an idea where to look for a bug or which tool to use to see what is happening when I press the link? URL mod rewrite? Domain configuration? I am at a loss.
It sounds like the scripts are getting confused between
[xttp://test.domain.com]/admin/file.php
admin/file.php
file.php
Without seeing how the URLs are generated it's impossible to say how this is happening.
I'm trying to understand code that I bought so I can modify it.
In the index.php there are picture links:
<a href="test10,10"><img title="" border=1
src="makethumb.php?pic=product_images/test101.jpg&w=121&sq=N" / ></a>
I don't understand the href since it is not pointing to a page. test10 is an id of a picture. I assumed it was going back to the index.php and the code would extract the test10,10 from the url, but it's not. I know that because I put in trace code as the first line.
The question is, where is the link going to?
I know it that it somewhere in the process it executes a page called profile.php, but nowhere in the source code (doing a global search) is there an explicit call to profile.php.
As a related question, is there a way to profile the code to see what pages it's calling without using xdebug, which for the life of me I can't get working after many hours of trying every suggestion I found here and else where. (I'm using xampp)
The flow is: you enter the site www.site.com/final/index.php. which displays pictures with the link as above. When you click on the picture with an id of test10 it takes you to www.site.com/final/test10,1
thanks
The question is, where is the link going to?
Under normal circumstances, a request to
www.yourdomain.com/current_directory/test10,10
is made.
Usually, Apache will try to find a file of that name, and fail.
If the behaviour you get is different, then there is probably a mod_rewrite rule set up somewhere. Look for .htaccess files (note, files in parent directories affect all children) and check the httpd.conf, httpd-vhosts.conf and other log files for any RewriteRule settings.