I use this url http://localhost/backend/backend/page/index, that it goes to 404 error page, but when I add / in the end of url, it works correctly.
I mean this url: http://localhost/backend/page/index/
Of course this problem is just for one of my urls. Other urls works without slash in ending url.
I have to add this, that the same url, that I have the same codes on another project, works without problem, and I don't need to add / in end of url. The problem is just in this project.
I use no urlmapping in my codes.
If you need more information, ask it.
Related
I am pretty new to htaccess and how to use them so you'l have to bear with me a little.
Example of what I am trying to achieve:
I am on a page with the following URL: https://www.example.com/you?source=hissite
While on this page I click on a link to another page of my site with an href of https://www.example.com/him.
Is it possible to use htaccess to append the parameters of the referal url into the requested url, this way I end up on https://www.example.com/him?source=hissite ?
This question gave me some good clues but I couldn't figure out how to append only the parameters. Redirect using htaccess based on referrer
I'm working on a website running on an Apache server. The PHP factory makes and takes URLs that look like this:
site.com/page/view/[id]/[vanity-url]
However, the client wants to hide part of the URL from view, so in the browser it appears as:
site.com/[vanity-url]
The server still needs to see the full URL.
I've tried various RewriteRules after hours of searching, and the closest I seem to have come is:
RewriteRule ^page/view/(.*)/(.*)$ /$2 [R,L]
...but that doesn't seem to be doing anything. I know for sure that my .htacces is working.
What am I doing wrong?
Unfortunately, this isn't possible. Let me explain why:
You state that the server needs to see the full URL. Specifically, this includes the id segment, which I am sure your framework needs (it wouln't need it if the server only needs to see the vanity segment). The code you have provided redirects the full URL to the vanity URL, thus making the full URL invisible to the server for the next request.
So, navigating to /page/view/2/about-us would redirect to /about-us, and the address bar would change to reflect that. This causes a new request to be sent to the server, containing only the /about-us vanity URL.
As a result, you would need to rewrite the vanity URL back to the full URL (without redirecting, so that the /about-us stays in the address bar as-is), but you wouldn't be able to do this, as the vanity URL does not contain the id segment, which seems to be a requirement for the framework to serve the correct response. Keep in mind that Apache cannot guess the ID for that particular vanity URL.
I need to be able to redirect versions of a product that returns a 404 error in a query string url back to the main product URL for example
www.domain.com/product.html?id=234 - 200 ok
www.domain.com/product.html?id=236 - 404 error
Leave /product.html?id=234 as it is due to it returning a 200 status
Redirect /product.html?id=236 to /product.html as it returns a 404 status
Is this possible via the .htaccess??
There is a statement that you can put in the htaccess to check if not found and send user to specified 404 page I was unsure if this could be used as a query string
Sure, but that only checks if product.html exists. It doesn't actually run any scripts to verify that id=236 is valid or not. You need to make the change in your script, the place where it validates the id parameter. If it finds that the ID is a 404, then it needs to do the redirect from there.
The htaccess file can't help you here.
I haven't found a solution to this, since all of my searching and research points to query string related issues when you're going from a file with a query string, over to another URL. In my case, I'm just looking to go from a regular folder/file, etc., to a URL with a query string.
I have a working .conf file which contains various rules for my site. I'd like to add in another one that looks like this:
RedirectMatch ^/webinar$ https://company.webex.com/company/onstage/g.php?t=a&d=123456
RedirectMatch ^/webinar/$ https://company.webex.com/company/onstage/g.php?t=a&d=123456
I've modified the URL to be more generic. This redirects properly when I type in www.company.com/webinar however, it's not going to the above URL. When I type in the above URL directly in a browser, it loads up fine.
The redirect is taking me to a generic Webex page. This could be an issue with the redirect, but I think it has to do with how RedirectMatch is handling the query string on this URL. I'm at a loss.
EDIT
There might be an issue in how I now have 3 redirects happening. The first is the /webinar, second is the above URL, and the third is that the above URL redirects to another page where quite frankly, webex may be handling iframes. Not 100% sure. So could the second redirect be borking the third, etc? I can provide more specifics as far as the webex URL's if required.
SOLUTION
The issue here is that Webex can't handle a double redirect which is what's happening. Instead, I had to leverage a PHP page with a header redirect in a separate folder off of the TLD. The above RedirectMatch syntax is correct, but for some reason, Webex borks it.
For SEO purposes. How do I force user gets redirected to mysite.com/index when types mysite.com on browser ?
I've tried Redirect / en/index
But I'm getting "Firefox has detected that the server is redirecting the request to this address in a way that will never end."
Also, can this redirection consired set language (php psession, cookies?)
p.s. xampp/windows
Redirect works on path prefixes. Redirect / … matches any path its prefix is / (so virtually any path). Use RedirectMatch instead:
RedirectMatch ^/$ /en/index
I believe the error you're getting from Firefox is because you're entering an infinite loop with this redirection. If you try to redirect to a page that doesn't exist, and your server is set up to redirect to a page that doesn't exist on 404, you'll enter a loop. So, ensure that your redirect is going somewhere significant. Does /index exist? Try redirecting to Google instead and see if you get the same error.
(My server knowledge is limited to goofing around while working on school projects, so take anything I say with a grain of salt)
This probably means you have an error in your redirect code. What Firefox is detecting is that the page are trying to view is redirecting you to itself. Without this protection it would just seem like the page wasn't loading.
If you are running windows on your workstation, I would recommend downloading Fiddler2. It will let you see the series of redirects that your server is sending.