I have a website with multiple folders and I was trying to fix them in my .htaccess. After a little while, I have a big .htaccess with rules that conflicts.
Now every time I want to add a folder I have to add it to the .htaccess.
I did some research and I found out I can create symbolic link instead, so no more .htaccess
In both solution I have to create or modify something so for me its the same result at the end but is it a better practice to create instead symbolic link ?
Symbolic links are faster yes (like Aki said) but here's my thoughts on this.
if you have images, css or js files then you don't need to rewrite or create symbolic links. You can use the full URL (eg /images/...) or use a common domain like i.domain.com (or anything you want) and refer all your JS, Images and CSS there. Eg: i.domain.com/logo.jpg or js.domain.com/site.js.
This way, you never have to think about rewriting rules or create links you might forget one day.
This one is very easy to manage and maintain if you need to add images, change js or update your CSS since you only have one point of entry and automatically everything be updated.
use symblink, .htaccess has to be proccesed by apache whereas the symblink are proccess by the OS which is faster.
creating 100 rules vs 100 symblink, if the rule you looking for is at the last you will have to parse all of them then use the one you need.
Related
Totally lost on how to set up a .htaccess file, bunch of stuff and only been able to redirect and set index.
I have a site https://subdomain.domain.com/views/list.html and I want it to show up as https://subdomain.domain.comIve been able to hide the views/list.html from that main page with DirectoryIndex views/list.html but when i come back to it from within the website it still shows up as subfolder.Also is it possible for other subfolder files to not show up as subfolder but as something else? e.g. https://subdomain.domain.com/views/add.html show up as https://subdomain.domain.com/addproduct
Have you thought about trying PHP indexing? Make a folder structure and place the indexer in the correct folder. As for the subbing, it should be possible, least from what I recall.
I would like to recreate old pages that were online 2 years ago. Unfortunately, all I have is the old htaccess file. Is there a way to find all used URLs?
Thanks in advance!
.htaccess does not store any information about pages or their urls. The only possible information to get is a redirection mechanism and/or some information regarding folders structure, if such was used. If you paste the source of your file here, one could help you with this. In general - in the most optimistic scenario you will just get a set of rules in the form of
regular Expression --> server query
(unless author did enumerate all the urls instead of using regular expressions)
Check the http://archive.org/web/web.php for some cached versions of your website.
How to prepare .htaccess file to block strange redirect...
When site is created in Cake, and we input address some like this: http://example.com/css, we are redirec to to http://example.com/app/webroot/css (403 Forbidden).
I think is the problem of .htaccess, but maybe no. The better solutions will be redirect to / or listing files if we can.
How solve this?
Cake expects http://example.com/css to redirect to http://example.com/app/webroot/css, which is where you should be keeping all your css files. You'll notice that doing things like echo $this->Html->css('style'); , the standard cake way for linking to a css style, it will create a link to http://example.com/css/style.css even though the file should be actually located in http://example.com/app/webroot/style.css. You do not want people to be able to look at http://example.com/css, since that is your css folder. If they can browse your file structure, they could potentially do bad things. So don't alter your .htacess file. As you said, whatever you're trying to do is most likely better done another way.
I have a website that's written using CakePHP. I've added some rewrite rules in the .htacces file to change the default urls to different ones (instead of /controller1/action1/parameter I have /some-string-about-controller-and-action/parameter, for example).
The problem is that now both the normal url and the nice one are available, and google seems to be indexing both, which is a problem. I'd like to only keep the nice one, which is the proper way to handle this so that it affects the google results as little as possible?
I don't know why you don't want to use cakes own routing (if you are having trouble doing what you want, you can accomplish what you want with a custom route class), then make sure that you redirect all relevant URL's in your .htaccess file to the desired URL using a MOVED PERMANENTLY redirect.
This way google will index the target url instead of the one that is undesirable. You are right to take offense to this, double indexing is a great way to harm your SEO rankings.
I'm trying to have relative links that are preceded with a forward slash (/) get rewritten with mod_rewrite to refer to the site root.
I have site:
http://localhost/mysite/
and I have numerous references, for example, in my css directory, formatted like such:
background: url('/img/background.jpg');
I would like to use mod_rewrite to point that at:
http://localhost/mysite/img/background.jpg
But right now, it is pointing to:
http://localhost/img/background.jpg
I apologize in advance if this is a no-brainer, but I'm new to mod_rewrite, and I have so far been unsuccessful in getting this to work!
This is not a good thing to do. It is duct-taping a mistake that should be fixed at its core.
By rewriting URLs this way, you risk breaking links in other sites on localhost, for example, and it is a long-term maintenance nightmare having to deal with URLs outside your site's root directory.
Consider using relative links in your CSS instead, e.g.
background: url('../img/background.jpg');
if the images are in a sibling directory of where your CSS style sheet is in.
Links in style sheets are always relative to the location the style sheet is in - not the HTML file that uses it. That makes it very easy to use relative links in style sheets.