I'm trying to make an error document show what page you were trying to go to, but am having issues as it does not escape characters by default (as ecpected)
Most solutions I've seen are to use RewriteRule, but I really do not want to do that, as I want the same document to handle many errors. My current solution is:
ErrorDocument 404 http://%{HTTP_HOST}/Error/Error?c=404&p=%{REQUEST_URI}
But that would break apart incases such as "example.com/NotExist&=&^72*(238"
Is there any way to do this?
Related
Is there any setting for url limit in Yii 2?
Some of my urls are over 300 characters and I get a 403 Forbidden code;
http://website/servicii-de-proiectare-asistenta-tehnica-din-partea-proiectantului-pe-perioada-derularii-lucrarilor-si-executie-de-lucrari-pentru-proiectul-%E2%80%9Emodernizare-drumuri-comunale-dc----dc----si-dc---a-de-pe-raza-comunei-lunca-judetul-boto-ani%E2%80%9D-863506-switch.html
If I shorten the url, it works.
this is my urlmanager rule:
'<title:(.*)>-<id:([0-9]+)>-access-not-granted.html' => 'member/licitatii/access-not-granted',
I tried to find some information regarding this issue and surprisingly enough, I didn't found a thing regarding URL length permitted.
However, I found a Yii way to solve your issue: Short URL Yii extension presented here - http://www.yiiframework.com/extension/google-url-shortener/
Also, please read this documentation that better explains how Yii treats URL routs: http://www.larryullman.com/2013/02/18/understanding-routes-in-the-yii-framework/
I know this does not solve your problem directly, but hope it gets you somewhere!
L.E: Here you have the bitly extension for Short URL's: http://www.yiiframework.com/extension/bitly-url-shortener/
Keep on coding,
Ares.
Why would that rule apply to your URL? From what I can see your URL will never trigger that rule.
I do not think there is a limit with the string of the URL in Yii2, try deleting some of the first part of the string to test this. try with an url like
http://website/proiectul-%E2%80%9Emodernizare-drumuri-comunale-dc----dc----si-dc---a-de-pe-raza-comunei-lunca-judetul-boto-ani%E2%80%9D-863506-switch.html
You might have problems because you have diacritics in the URL, try without them.
I am a bit new to this but I am trying to learn. I know that in PHP we can have a URL that ends in ?id=something but it seems to me that some websites are doing it just forward slashes. Is this possible using PHP? I saw these questions that seem to say it is possible but I haven't cracked it yet.
Can someone prompt me in the right direction for mod_rewrite? I would like to change the following URL
http://www.example.com/all-products/?onsale=true&topic=health&item=adaaos45
into
http://www.example.com/all-products/items-on-sale/health/adaaos45
Can you point me into the right way?
What you are looking for is Apache Url Rewriting.
I will break it down a bit for you to help you understand, it helps to know a bit of regex.
there are a lot of answers here that discuss the method, but to sum it all up, you need to do three things.
# Switch on URL Rewriting
# Choose the URL that you want to display
# Point it to the true URL that gives the information.
Options FollowSymLinks
RewriteEngine On
RewriteRule ^all-products/items-on-sale/health/adaaos45/?$ all-products/?onsale=true&topic=health&item=adaaos45 [NC,L]
Now of course, if you would want to match any results for the variables, you need to match the word in regex, and remember it, and use it in the last part of the line. But this should get you started on understanding what is going on.
With this code in your .htaccess, browsing to
http://www.example.com/all-products/items-on-sale/health/adaaos45
will show you the content that displays on this page.
http://www.example.com/all-products/?onsale=true&topic=health&item=adaaos45
I have a problem with lots of 404 errors on one site. I figured out that these errors are happening because google is trying to find pages that no longer exist.
Now I need to tell Google not to index those pages again.
I found some solutions on the internet about using robots.txt file. But this is not a site that I built. I just need to fix those errors.The thing is, those pages are generated. They do not physically exist in that form. So I can not add anything in php code.
And I am not quite sure how to add those to robot.txt.
When I just write:
*User-agent: *
noindex: /objekten/anzeigen/haus_antea/5-0000001575*
and hit test button in webmaster tools
I get this from Googlebot:
Allowed
Detected as a directory; specific files may have different restrictions
And I do not know what that means.
I am new in this kind of stuff so please write your answer as simpler as it can be.
Sorry for bad english.
I think Google will remove such pages that return a 404 error automatically from its index. Google will not display these pages in the results. So you don't need to care about that.
Just make sure, that these pages are not linked from other pages. If so, Google may try to index them from time to time. In this case you should return a 301 error (permanently moved) and redirect to the correct url. Google will follow the 301 errors and use the redirected url instead.
Robots.txt is only necessary, if you want to remove pages that are already in the search results. But I think pages with error code 404 will not be displayed there anyway.
I've been looking for an answer to this forever and can't find it, yet it seems like it should be so simple!
I want to use mod_rewrite to replace a word in a url in every instance that it shows up, but I don't want a redirect to happen, just changing the way the url appears to site users.
Example:
Change
mysite.com/something/groups/anything...
to:
mysite.com/something/projects/anything...
I know I could go through and start tweaking files but mod_rewrite would work much better because I'm sure I'll mess something up otherwise (for reference I'm using joomla/jomsocial).
RewriteEngine On
RewriteRule something/groups/.*$ something/projects/$1
Couple of months ago, we revamped our web site. We adopted totally new site structure, specifically merged several pages into one. Everything looks charming.
However, there are lots of dead links which produce a large number of 404 errors.
So how can I do with it? If I leave it alone, could it bite back someday, say eating up my pr?
One basic option is using 301 redirect, however it is almost impossible considering the number of it.
So is there any workaround? Thanks for your considering!
301 is an excellent idea.
Consider you can take advantage of global configurations to map a group of pages. You don't necessary need to write one redirect for every 404.
For example, if you removed the http://example/foo folder, using Apache you can write the following configuration
RedirectMatch 301 ^/foo/(.*)$ http://example.org/
to catch all 404 generated from the removed folder.
Also, consider to redirect selectively. You can use Google Webmaster Tools to check which 404 URI are receiving the highest number inbound links and create a redirect configuration only for those.
Chances are the number of redirection rules you need to create will decrease drastically.
301 is definitely the correct route to go down to preserve your page rank.
Alternatively, you could catch 404 errors and redirect either to a "This content has moved" type page, or your home page. If you do this I would still recommend cherry picking busy pages and important content and setting up 301s for these - then you can preserve PR on your most important content, and deal gracefully with the rest of the dead links...
I agree with the other posts - using mod_rewrite you can remap URLs and return 301s. Note - it's possible to call an external program or database with mod_rewrite - so there's a lot you can do there.
If your new and old site don't follow any remapable pattern, then I suggest you make your 404 page as useful as possible. Google has a widget which will suggest the page the user is probably looking for. This works well once Google has spidered your new site.
Along with the other 301 suggestions, you could also split the requested url string into a search string routing to your default search page (if you have one) passing those parameters automatically to the search.
For example, if someone tries to visit http://example.com/2009/01/new-years-was-a-blast, this would route to your search page and automatically search for "new years was a blast" returning the best result for those key words and hopefully your most relevant article.