I would like a website to initially display intro.html when coming from external websites like google, or just from typing in the url. This intro.html and all internal links will link to index.php (wordpress blog so index.php can't change filename) which will then serve as the homepage. Can i do this with .htaccess, perhaps some rewritecond only on external links?
Yes, just redirect every request that does not come from your website, you can check this with HTTP_REFERER. This article should get you on the right path.
Related
I am currently administrating some art website that contains lots of photos and other content files and it bugs me that ppl find a way around scripting and are accessing stuff directly, they download our copyright protected materials.
I was thinking about htaccess file that do the following:
someone type in address directly to the browser: http://www.mydomain.com/photos/photo.jpg
htaccess triggers and instead of showing the content - it redirects right away to: http://www.mydomain.com/ (this is important to do redirect before picture is displayed)
redirect is extremely important not just some preventing without redirect, but if someone attempts to use sowftware to download content via providing link to it then it rejects request
my knowledge about htaccess is really thin i could use a help on this one
This should work:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.com/ [NC]
RewriteRule .*\.jpg|gif$ /nolinking.html [R]
If you try enter http://www.mydomain.com/photos/photo.jpg it will redirect you to http://www.mydomain.com/nolinking.html, but it will allow images to be loaded on pages if they are linked to,
I would like to change our site structure a little bit and decided to have the product overview not in http://www.example.com/en/ but in http://www.example.com/en/products/
I did not manage it to redirect it from /en/ to /en/products/ (or /en to /en/products/).
The page is not online so far (Testmode) and I don't have to care about 301 Pages for Google at the Moment.
Can anybody help?
After you've been able to successfully create a url rewrite how do you handle the original and other possibly ways to access a page. This of course to prevent duplicate content. For example if I have this:
RewriteEngine on
RewriteBase /
RewriteRule ^blog/(\d+)/([\w\-/\.]+)/?$ blog.php?id=$1&article_title=$2 [L]
I'm able to access the page by the url
https://www.mysite.com/blog/10/mysite.com (the mysite.com is the article title)
The problem is I'm also able to access the site by going to
https://www.mysite.com/blog.php?id=10article_title=sitetitle
https://www.mysite.com/blog.php?id=10
ect.
How are you supposed to handle those particular urls.
Also should I change the blog.php?id=10 to the rewritten url? Can I rely on something else and just start using the full rewritten url now? The site is new.
For my web site, I have the script that gets called from inside the rewrite detect the URI they were fetched from (using the "REQUEST_URI" variable that at least Apache sets), and redirect to the canonical one if they ever get called with the internal one (outputting a 301 direction).
I have just been asked to migrate a site from one server to another for a site that I did not build. They have a lot of links to pages that dont exist.
<a href="app/batteries">
This is not actually a directory in the site, but there is an app.php file in the root directory. I have gotten it to display the products by redirecting anything to the app/ directory to app.php?app=. The value of ?app= is dynamic, so any solution would need to be dynamic. I have simply used the redirect statement in the htaccess file to get it to the app.php page. Is there a way to get the url back to the pretty url after a redirect?
Any help would be awesome. Thanks in advance.
You should use ModRewrite instead, for matching a pretty url with regexps, and converting into the url using the app.php.
The rewrite is local to the server, so the visitor sees only pretty urls.
I've tried many options in .htaccess without success. What I want to do is this:
I have Wordpress residing in its own folder, like this: site.com/folder
I want all users visiting site.com to be redirected to site.com/folder/page but in such a way that the URL doesn't change in the browser. All other URLs, such as site.com/folder and site.com/folder/page1 etc shouldn't be affected.
How to do this, in as SEO-friendly way as possible?
Thanks everyone.
You can't redirect a user to a other page from serverside without to show this to the use.
But if you need, you can use the HTML tag <frame> http://www.w3schools.com/tags/tag_frame.asp
But the bad side with this is the use always will be show "site.com" and not the real page.
But I think the best way is to proxy the result, in Apache you can do this by something like this.
RewriteEngine ON
RewriteRule ^/$ folder/page/index.php [L]