I have a single page website
http://picniclounge.com/parallax-page/index.html
I would like it to read picniclounge.com/ and not with the folder and index.html at the end.
How can I do this using htaccess?
You can use this in your htaccess:
DirectoryIndex /parallax-page/index.html
Related
So I have hosted my laravel app in a subfolder lets now refer the root of my project as subfolder. I have a constant base file which has header and footer of the website, I used link of images as
<img src="/img/img1.png">
so it goes to domain.com/img/img1.png instead of domain.com/subfolder/img/img1.png
and if I do
<img src="img/img1.png">
it works fine for the first page but when I navigate to subfolder/user/1 my images brake again because now they are finding images on subfolder/user/1/img/img1.png. I remember once I ran into such situation and someone helped me to set the path of images by adding one line in the header of the website but now I am not able to find it.
Check your root Folder is correct
To avoid this problem, make use of asset() or url() function:
<img src="{{ url(img/img1.png) }}">
Edit: if you plan to attach "subfolder" in url path, then try to edit .htaccess file:
RewriteEngine on
RewriteRule ^/img/(.*)$ http://%{HTTP_HOST}/subfolder/img/$1 [L,R=301]
The code above searches the image /subfolder/img/img1.png when /img/img1.png is found.
I don't want the search engines to index my imprint page. How could I do that?
Also you can add following meta tag in HEAD of that page
<meta name="robots" content="noindex,nofollow" />
You need a simple robots.txt file. Basically, it's a text file that tells search engines not to index particular pages.
You don't need to include it in the header of your page; as long as it's in the root directory of your website it will be picked up by crawlers.
Create it in the root folder of your website and put the following text in:
User-Agent: *
Disallow: /imprint-page.htm
Note that you'd replace imprint-page.html in the example with the actual name of the page (or the directory) that you wish to keep from being indexed.
That's it! If you want to get more advanced, you can check out here, here, or here for a lot more info. Also, you can find free tools online that will generate a robots.txt file for you (for example, here).
You can setup a robots.txt file to try and tell search engines to ignore certain directories.
See here for more info.
Basically:
User-agent: *
Disallow: /[directory or file here]
<meta name="robots" content="noindex, nofollow">
Just include this line in your <html> <head> tag. Why I'm telling you this because if you use robots.txt file to hide your URLs that might be login pages or other protected URLs that you won't show to someone else or search engines.
What I can do is just accessing the robots.txt file directly from your website and can see which URLs you have are secret. Then what is the logic behind this robots.txt file?
The good way is to include the meta tag from above and keep yourself safe from anyone.
Nowadays, the best method is to use a robots meta tag and set it to noindex,follow:
<meta name="robots" content="noindex, follow">
Create a robots.txt file and set the controls there.
Here are the docs for google:
http://code.google.com/web/controlcrawlindex/docs/robots_txt.html
A robot wants to vists a Web site URL, say http://www.example.com/welcome.html. Before it does so, it firsts checks for http://www.example.com/robots.txt, and finds:
you can explicitly disallow :
User-agent: *
Disallow: /~joe/junk.html
please visit below link for details
robots.txt
I don't know exactly what is the problem, but I have done a lot of research about trailing slash in PHP.
My problem is that when I visit my site I always see trailing slash and it causes all the resources to fail to load.
How do I disable trailing slash that's being added in .htaccess.
Thanks!
PHP does not add / to URLs by default, it's your script doing that.
If you want to use the style.css regardless, use the absolute or the full path - so if your style.css is on http://domain.com/style.css, then you can either use
<link rel="stylesheet" type="text/css" href="/style.css">
or
<link rel="stylesheet" type="text/css" href="http://domain.com/style.css">
With your file.php thing, it looks in http://domain.com/file.php/style.css, while either of the above uses the file you created at http://domain.com/style.css.
That would as well work for http://domain.com/folder/file.php - simply use /folder/style.css in the href-tag or, once again, the full URL to it.
The / in a URL indicates a directory on the file systen of your webserver so your request for file.php/ is looking for a directory and not a PHP script file.
A htaccess rewrite so that any directory automatically has a trailing slash appended can be found in the rewrite guide:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R]
Here is what I found:
Remove the trailing slash in url with htacess
I think this is what you are looking for.
How to find it:
Just do a search for remove ending slash of url
just use the full path to the css file for eg.
<link rel="stylesheet" type="text/css" href="http://yourdomain/folder/file.css"/>
I have this code in my .htacess file :
RewriteEngine On
RewriteRule ^article/(\d.*) article.php?id=$1
When I open a link like this:
http://localhost/mysite/article/10
The page will open but no images, CSS, JS file loaded, I guess the problem is that pages are going to this URL article/10, so every URL in the article.php is changing to new URL even after redirect works.
How I can fix this problem?
This depends on where your resources are stored and how they are linked in your article, your article will need to point to something like http://localhost/mysite/image to reference an image without it being redirected by your script
I am developing a website, and I have set up the following htaccess rules
RewriteEngine On
#RewriteRule ^([0-9]+)?$ index.php?page=$1
#RewriteRule ^([0-9]+)/([0-9]+)?$ index.php?page=$1&post=$2
RewriteRule ^([A-Za-z0-9-]+)?$ index.php?pagename=$1
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)?$ index.php?pagename=$1&post=$2
This ensures that instead of http://www.mysite.com/index.php?page=2 showing the page
I get to use the friendlier method of http://www.mysite.com/about-us
* note I have not included a trailing slash.
In the page my css files are included as:
<link href="css/style.css" rel="stylesheet" type="text/css" />
and located at www.mysite.com/css/style.css
And this works well, however if I want to include a trailing slash (i.e. http://www.mysite.com/about-us/)
Then my css files do not load and I get an error where the Firefox source browser says:
The requested URL http://www.mysite.com/about-us/css/style.css was not found on this server.
This is because the page is determining about-us to be a directory instead of a page.
I am not keen to use the basehref tag like <base href="http://www.mysite.com/" />
Are there any other options?
Relative URLs are resolved from a base URL that is the URL of the document the relative URL is used in if not specified otherwise.
Now to fix this incorrect reference, you have two options:
change the base URL using the BASE element,
change the reference
by adjusting the relative URL path to the base URL path, or
by using just an absolute URL path, or
by using an absolute URL.
Since you don’t want to use the BASE element, you will probably need to adjust the URL you are using to reference the external resource.
The simplest would be to use the absolute URL path /css/style.css instead so that it is independent from the actual base URL path.